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 |
Explain what you mean by a pointer.
int age=35; if(age>80) {Console.WriteLine("Boy you are old");} else {Console.WrieLine("That is a good age");}
What are the uses of typedef in a program?
What should main() return in c and c++?
What is a storage class in C++
Does improper inheritance have a potential to wreck a project?
What is setfill c++?
Discussion on error handling of C++ .
In the derived class, which data member of the base class are visible?
C is to C++ as 1 is to a) What the heck b) 2 c) 10
Is dev c++ a good compiler?
how to explain our contribution in the project?