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 character terminates all character array strings a) b) . c) END
Write about the local class and mention its use?
What is c++ hash?
Difference between Top down and bottom up approaches for a given project ?
14 Answers BSNL, CSC, HCL, HP, IIT, Infosys, Siemens,
What is cin clear () in c++?
What are the two types of polymorphism?
Can you please explain the difference between overloading and overriding?
write a program that takes 5 digit no and calculate 2 power that no and print it.
What is a tuple c++?
What is the full form of stl in c++?
What is an operator function? Describe the function of an operator function?
Can c++ be faster than c?