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 object in oops?
What are constructors in oop?
Describe these concepts: Polymorphism, Inheritance and Abstraction.
What is object-oriented programming? Webopedia definition
why reinterpret cast is considered dangerous?
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?
Write a program to reverse a string using recursive function?
write string class as your own class in java without using any built-in function
Can we define a class within the interface?
What is protected in oop?
write a programe to calculate the simple intrest and compund intrest using by function overlading
What is overloading and its types?
Advantage and disadvantage of routing in telecom sector
What type of loop is a for loop?
What are the 4 main oop principles?