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

Answers were Sorted based on User's Feedback



what is object slicing..

Answer / subhashish saha

When you try to assign derived class object to an object of
base class, it takes the elements that has relivance with
respect to the base class and slices off the remaining
thing. this is object slicing...

Is This Answer Correct ?    27 Yes 1 No

what is object slicing..

Answer / 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

what is object slicing..

Answer / ravi

OBJECT SLICING IS ALSO USED IN THE VIRTUAL FUNCTION
TO USE TO ACCESS THE DATA MEMBER OF DRIVED CLASS

Is This Answer Correct ?    0 Yes 9 No

Post New Answer

More OOPS Interview Questions

What is virtual constructors/destructors?

4 Answers   IBS,


What is the difference between abstraction and polymorphism?

0 Answers  


Name an advantage of linked list over array?

11 Answers   IBM, Infosys,


write a c++ code of diagonal matrix.

2 Answers  


What is overriding vs overloading?

0 Answers  


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

3 Answers   HCL,


sir i want to know which posting to apply since i am BE CSE.. also want to know what are the rounds there for my interview...Expecting for ur valuable answer....

2 Answers  


What are the 3 pillars of oop?

0 Answers  


Write a program to implement OOPS concepts such as inheritance, polymorphism, friend function, operator overloading?

0 Answers   TCS,


What is the difference between class and object?

4 Answers   Apple, Heinz,


what is the difference between function template and template of function?explain with example.

2 Answers  


what is difference between objects and function

1 Answers  


Categories