Answer Posted / 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 |
Post New Answer View All Answers
What is token c++?
what is c++
What are the types of array in c++?
Differentiate between realloc() and free().
What is the difference between method overloading and method overriding in c++?
What do you mean by static variables?
What are register variables?
How many keywords are used in c++?
What is the latest c++ version?
How are pointers type-cast?
What is a down cast?
what is Loop function? What are different types of Loops?
How do you flush std cout?
Write about the access privileges in c++ and also mention about its default access level?
How is data hiding achieved in c++?