What is object slicing and how can we prevent it?
Answers were Sorted based on User's Feedback
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 |
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 |
What are the uses of c++ in the real world?
What is the basic concept of c++?
What is a loop? What are different types of loops in c++?
What is vector pair in c++?
What is null and void pointer?
Which of the following is evaluated first: a) && b) || c) !
Do you know about latest advancements in C++ ?
0 Answers Agilent, ZS Associates,
class X { private: int a; protected: X(){cout<<"X constructor was called"<<endl;} ~X(){cout<<"X destructor was called"<<endl} }; Referring to the code above, which one of the following statements regarding "X" is TRUE? a) X is an abstract class. b) Only subclasses of X may create X objects. c) Instances of X cannot be created. d) X objects can only be created using the default copy constructor. e) Only friends can create instances of X objects.
How do you print for example the integers 3,2,1,5,4 in a binary tree within the console in format where it looks like an actual binary tree?
What is flag in computer?
If we declare two macro with the same identifier without doing undef the first, what will be the result? eg: #define MAX_SIZE 100 #define MAX_SIZE 200 int table1[MAX_SIZE];
What is the purpose of templates in c++?