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 meant by the term name mangling in c++?

0 Answers  


what is the use of void main() in C++ language?

0 Answers  


Can c++ be faster than c?

0 Answers  


sir there is some problem with nokia5130c-2,when we are trying to upload movies from net then there is a error occurred"FORMAT NOT SUPPORTED" bt its all ready in 3gp format.please tell me what i do now?

2 Answers   Nokia,


Explain the scope resolution operator?

2 Answers  






What is a reference in C++?

1 Answers  


What is the size of pointer ? Also size of pointer in 64 bit pointer

4 Answers  


How can you link a c program with a c function?

0 Answers  


What is c++ code?

0 Answers  


Describe the process of creation and destruction of a derived class object?

0 Answers  


Explain the difference between realloc() and free() in c++?

0 Answers  


Write a program that read 2o numbers in and array and output the second largest number. Can anybody help??

7 Answers  


Categories