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
Is it possible to provide default values while overloading a binary operator?
How to access a variable of the structure?
List the merits and demerits of declaring a nested class in C++?
what is oops and list its features in c++?
How do you establish a has-a relationship?
What is the fastest c++ compiler?
What is the importance of mutable keyword?
Explain function overloading and operator overloading.
What is lambda expression c++?
Differentiate between late binding and early binding.
Which sort does c++ use?
Explain dangling pointer.
What is the difference between multiple and multilevel inheritance in c++?
Explain the isa and hasa class relationships. How would you implement each?
Who invented turbo c++?