What is object slicing and how can we prevent it?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Do class declarations end with a semicolon? Do class method definitions?

614


What is the use of turbo c++?

551


How is computer programming useful in real life?

594


How static variables and local variablesare similar and dissimilar?

555


Is c++ the hardest language?

561






Why are pointers not used in c++?

626


What is an object in c++?

607


Why is main function important?

583


Why is standard template library used?

577


What are vtable and vptr?

611


What do the keywords volatile and mean mutable?

601


Can we use this pointer in a class specific, operator-overloading function for new operator?

611


What is a singleton c++?

545


Is map sorted c++?

513


What are different types of loops in c++?

652