OOPs Concepts Interview Questions and Answers
<< Previous Question Next Question >>
 Question: 8205 Page Views: 

What do you mean by Object Slicing?



Posted By: Avi Date: 8 October 2009 02:55:39 AM
 Answer:

When a derived class object is assigned to a base class, only the base class's part of content 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 objB;
Derived objD;
objB = objD;
//Here objD contains both i and j.
//But only i is copied to objB.
}


Posted By: eTechPlanet


Date: 8 October 2009 02:55:39 AM
Post a better Answer if you have
 
(Will show your Gravatar icon)  
  Country flag

Loading
Enter the text as shown in the image 1La8XG
Related Questions
OOPs Concepts : What is Polymorphism?

What is Polymorphism?

Polymorphism is an ability to appear in many forms. It refers to the ability of the system to call c....
Category: OOPs Concepts Date: 8/29/2009 7:03:57 PM
OOPs Concepts : What is Inheritance?

What is Inheritance?

In OOPs terminology, inheritance is a way to form new classes using classes that have already been d....
Category: OOPs Concepts Date: 8/29/2009 6:52:23 PM
OOPs Concepts : What is Abstraction?

What is Abstraction?

Abstraction is the process of generalization by reducing the information content of an entity, typic....
Category: OOPs Concepts Date: 8/29/2009 6:45:58 PM
OOPs Concepts : What is Encapsulation?

What is Encapsulation?

In OOPs terminology, Encapsulation refers to encapsulating data with the methods that operates on th....
Category: OOPs Concepts Date: 8/29/2009 6:25:10 PM
OOPs Concepts : What is an Object?

What is an Object?

Instances of classes are called as objects. The class of Employee defines all possible employees by....
Category: OOPs Concepts Date: 8/29/2009 8:07:26 AM