What is object slicing and how can we prevent it?

Answers were Sorted based on User's Feedback



What is object slicing and how can we prevent it?..

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

What is object slicing and how can we prevent it?..

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

Post New Answer

More C++ General Interview Questions

What is low level language in simple words?

0 Answers  


What is a singleton c++?

0 Answers  


Explain the ISA and HASA class relationships. How would you implement each in a class design?

3 Answers  


Please explain class & object in c++?

0 Answers  


What is static class data?

0 Answers  






What is binary search in c++?

0 Answers  


What is lvalue?

0 Answers  


What are Binay tress and B trees? Diff between them?

8 Answers   CTS, GATE, Wipro,


Write a program to find the Fibonacci series recursively.

0 Answers   Huawei,


What jobs can you get with a c++ certification?

0 Answers  


What is the difference between a reference and a pointer?

0 Answers  


What is polymorphism and its type in c++?

0 Answers  


Categories