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 program using GUI concept for the scheduling algorithms in Operating system like SJF,FCFS etc..
How do you differentiate between overloading the prefix and postfix increments?
Why cstdlib is used in c++?
Is java a c++?
Why is it called c++?
How Virtual functions call up is maintained?
How many lines of code you have written for a single program?
What is conversion constructor?
What are the characteristics of friend functions?
What is encapsulation in c++?
What is a local variable?
What is difference between class and function?