Answer Posted / kar4you
When a Derived Class object is assigned to Base class, the
base class' contents in the derived object are copied to
the base class leaving behind the derived class specific
contents. This is referred as Object Slicing. That is, the
base class object can access only the base class members.
This also implies the separation of base class members from
derived class members has happened.
class base
{
public:
int i, j;
};
class derived : public base
{
public:
int k;
};
int main()
{
base b;
derived d;
b=d;
return 0;
}
here b contains i and j where as d contains i, j& k. On
assignment only i and j of the d get copied into i and j of
b. k does not get copied. On the effect object d got sliced.
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
What is pure oop?
What is super in oop?
When not to use object oriented programming?
Why is encapsulation used?
What is static in oop?
What is encapsulation process?
What is encapsulation c#?
What is the difference between static polymorphism and dynamic polymorphism?
What is this pointer in oop?
State what is encapsulation and friend function?
What is polymorphism explain its types?
What does oop mean in snapchat?
What are main features of oop?
i am getting an of the type can not convert int to int *. to overcome this problem what we should do?
What is overriding vs overloading?