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 a vector?
How do you instruct your compiler to print the contents of the intermediate file showing the effects of the preprocessor?
What are the 3 levels of programming languages?
What is the role of copy constructor in copying of thrown objects?
Is empty stack c++?
Write a c++ code that will calculate the roots of a quadratic equation a2+ bx+c=0 Hint: d = sqrt (b2-4ac), and the roots are: x1 = (€“b + d)/2a and x2 = (€“b €“ d)/2a (use sqrt function from cmath.h )?
What is size of Empty Class?
Give a very good method to count the number of ones in a "n" (e.g. 32) bit number.
Define a nested class.
What are the different data types present in C++?
What is flush programming?
Can I learn c++ without learning c?