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

What is enum c++?

614


If there are two catch statements, one for base and one for derived, which should come first?

570


What is the maximum combined length of command line arguments including the space between adjacent arguments?

590


When does a name clash occur in c++?

711


What is the real purpose of class – to export data?

613






What is data types c++?

542


How many ways can a variable be initialized into in C++?

594


What is the use of volatile variable?

597


How much do coding jobs pay?

546


If a function doesn’t return a value, how do you declare the function?

611


Explain polymorphism?

581


What do you mean by stack unwinding in c++?

725


What is prototype for that c string function?

684


What is data hiding c++?

597


What is c++ namespace?

708