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 |
Suppose that data is an array of 1000 integers. Write a single function call that will sort the 100 elements data [222] through data [321].
How do you generate a random number in c++?
Write a single instruction that will store an EVEN random integer between 54 and 212 inclusive in the variable myran. (NOTE only generate EVEN random numbers)
When should you use multiple inheritance?
What is meant by a delegate?
Can you declare an array without a size in c++?
how to find the maximum of 10 numbers ?
What is const in c++?
What is a class template in c++?
What are static variables?
Which bitwise operator is used to check whether a particular bit is on or off?
Is std :: string immutable?