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 |
Write a corrected statement in c++ so that the statement will work properly. if (4 < x < 11) y=2*x;
Can you declare an array without a size in c++?
Is c# written in c++?
Which is not a valid keyword a) public b) protected c) guarded
What is an associative container in c++?
What is the advantage of c++ over c?
write a corrected statement so that the instruction will work properly. if (4 < x < 11) y = 2 * x;
What is the difference between method and message?
Which is best c++ or java?
print first nodd numbers in descending order
What is std :: endl?
What is abstraction in c++?