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 |
What are the various access specifiers in c++?
What is the function of I/O library in C++ ?
Describe public access specifiers?
what is the behaviour of C and C++ compiler for the below statements. int *p; p = malloc(100); Is the behaviour same ? or different ?
Explain storage qualifiers in c++.
What is a storage class used in c++?
Is there a new/delete equivalent of realloc?
Describe run-time type identification?
how to create window program in c++.please explain.
what is importance of data sturture in a programming language?
22 Answers L&T, TCS, Wipro,
What is conditions when using boolean operators?
What are the vectors in c++?