What is object slicing and how can we prevent it?
Answers were Sorted based on User's Feedback
Answer / prits
When an instance of derived class is assigned to base class
instance object slicing takes place.ie in this case the
derived portion gets truncated and only the base portion
remains.
The problem of object slicing can be prevented by the use
of pure virtual functions.
Is This Answer Correct ? | 38 Yes | 6 No |
Answer / vikas
Object slicing occurs when we assign an instance of the
subclass to a variable of type base class.
http://www.cppquestions.com/viewtopic.php?f=17&t=49
Is This Answer Correct ? | 12 Yes | 9 No |
Is oops and c++ same?
What is a pointer how and when is it used?
What are manipulators in c++ with example?
Why is c++ not purely object oriented?
Is c the same as c++?
when can we use copy constructor?
given unsigned int ui1=3,ui2=7; what are the outputs of a)ui1 & ui2 b)ui1 && ui2 c)ui1 | ui2 d)ui1 || ui2 i also need the justification for the answers thank you
If you want to share several functions or variables in several files maitaining the consistency how would you share it?
Who invented turbo c++?
What are the advantage of using register variables?
If a header file is included twice by mistake in the program, will it give any error?
What is the best sorting algorithm, when there is a large amount of data, that cannot be fit in the main memory. ?