Answer Posted / rsn
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.
Class Base
{
public:
int i;
};
class Derived : public Base
{
public:
int j;
};
int main()
{
Base Bobj;
Derived Dobj;
Bobj = Dobj; //Here Dobj contains both i and j.
//But only i is copied to Bobj.
}
| Is This Answer Correct ? | 126 Yes | 10 No |
Post New Answer View All Answers
What is the difference between inheritance and polymorphism?
What is the significance of classes in oop?
Which is better struts or spring?
What is for loop and its syntax?
They started with the brief introduction followed by few basic C++ questions on polumorphism, inheritance and then virtual functions. What is polymorphims? How you will access polymorphic functions in C? How virtual function mechanism works?
Can private class be inherited?
What are functions in oop?
What is coupling in oops?
What is encapsulation with real life example?
Which language is not a true object oriented programming language?
Why can't we have instance(stack) of a class as a member of the same class like eg.Class A{A obj;} as we can have self refential pointer
Write a program to sort the number with different sorts in one program ??
What is the real time example of inheritance?
#include
Why is there no multiple inheritance?