What is object slicing and how can we prevent it?

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain object slicing in c++?

687


What is an adjust field format flag?

765


What do you mean by vtable and vptr in c++?

721


Explain how the virtual base class is different from the conventional base classes of the opps.

794


Can static member variables be private?

711






In which situation the program terminates before reaching the breakpoint set by the user at the beginning of the mainq method?

691


What is ios class in c++?

661


How can you quickly find the number of elements stored in a static array? Why is it difficult to store linked list in an array?

664


What is the equivalent of Pascal's Real a) unsigned int b) float c) char

670


What are the benefits of oop in c++?

694


What is the difference between an external iterator and an internal iterator?

710


Why cout is used in c++?

662


Difference between a homogeneous and a heterogeneous container

762


Show the declaration for a pointer to function returning long and taking an integer parameter.

667


Difference between pointer to constant vs. Pointer constant

700