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

Why is it so that we can have virtual constructors but we cannot have virtual destructors?

4902


What are the components of marker interface?

1043


what's the basic's in dot net

2168


Why do we need polymorphism in c#?

1142


Write a c++ program to display pass and fail for three student using static member function

3379


What is oops and its features?

1051


Can destructor be overloaded?

1018


Why is destructor used?

1005


What is encapsulation in oop?

1026


write a program to find 2^n+1 ?

2047


What are the two different types of polymorphism?

1126


Prepare me a program for the animation of train

2459


How to call a non virtual function in the derived class by using base class pointer

6508


Why is there no multiple inheritance?

983


What are the 3 pillars of oop?

1163