What is slicing?
Answer / atul shankhwar
Slicing means that the data added by a subclass are discarded when an object of the subclass is passed or returned by value or from a function expecting a base class object.
Explanation:
Consider the following class declaration:
class base
{
...
base& operator =(const base&);
base (const base&);
}
void fun( )
{
base e=m;
e=m;
}
As base copy functions don't know anything about the derived only the base part of the derived is copied. This is commonly referred to as slicing. One reason to pass objects of classes in a hierarchy is to avoid slicing. Other reasons are to preserve polymorphic behavior and to gain efficiency.
| Is This Answer Correct ? | 0 Yes | 0 No |
How would you use the functions randomize() and random()?
why the size of an empty class is 1
Is c++ free?
What are the steps in the development cycle?
Explain how overloading takes place in c++?
What is a static member?
What is boyce codd normal form in c++?
Can c++ be faster than c?
What is c++ similar to?
What is meant by entry controlled loop? What all C++ loops are exit controlled?
given unsigned int ui1=3,ui2=7; what are the outputs of a)ui1 & ui2 b)ui1 && ui2 c)ui1 | ui2 d)ui1 || ui2 i also need the justification for the answers thank you
Define a pointer to a data member of the type pointer to pointer?