Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is object slicing

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


Please Help Members By Posting Answers For Below Questions

What is the difference between procedural programming and oops?

1203


Can you explain polymorphism?

1154


what's the basic's in dot net

2231


What is destructor oops?

1153


What is class and example?

1262


What is abstraction in oops?

1091


Is enum a class?

1113


What is object in oop?

1170


What language is oop?

1075


write knight tour problem which is present in datastructure

2713


Why is polymorphism needed?

1126


IS IT NECESSARY TO INITIALIZE VARIABLE? WHAT IF THE INSTANCE VARIABLE IS DECLARED final ? IS IT NECESSARY TO INITIALIZE THE final VARIABLE AT THE TIME OF THEIR DECLARATION?

2108


What is polymorphism and why is it important?

1098


Can we create object of abstract class?

1147


What is multilevel inheritance in oop?

1086