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 |
What is the size of pointer ? Also size of pointer in 64 bit pointer
Is arr and &arr are same expression for an array?
What is the purpose of decltype?
daily Routine of father
Live example for static function?
Can you explicitly call a destructor on a local variable?
what are the decision making statements in C++? Explain if statement with an example?
How long does this loop run: for(int x=0; x=3; x++) a) Never b) Three times c) Forever
17 Answers Datavance, Quark, VEL, Wipro,
What are C++ inline functions?
What is a constant? Explain with an example.
How does throwing and catching exceptions differ from using setjmp and longjmp?
Can we define function inside main in c++?