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 slicing?



What is slicing?..

Answer / atul shankhwar

Slicing means that the data added by a subclass are discarded when an object of the subclass is passed or returned by value or from a function expecting a base class object.
Explanation:
Consider the following class declaration:
class base
{
...
base& operator =(const base&);
base (const base&);
}
void fun( )
{
base e=m;
e=m;
}
As base copy functions don't know anything about the derived only the base part of the derived is copied. This is commonly referred to as slicing. One reason to pass objects of classes in a hierarchy is to avoid slicing. Other reasons are to preserve polymorphic behavior and to gain efficiency.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

Can you please explain the difference between static and dynamic binding of functions?

0 Answers  


What is realloc() and free()? What is difference between them?

1 Answers  


What are Binay tress and B trees? Diff between them?

8 Answers   CTS, GATE, Wipro,


What is the type of 'this' pointer?

0 Answers  


How can we access protected and private members of a class?

0 Answers  


How does a C++ structure differ from a C++ class?

0 Answers   NIIT,


Why c++ is so important?

0 Answers  


Will c++ be replaced?

0 Answers  


If dog is a friend of boy and boy is a friend of house, is dog a friend of house?

0 Answers  


make a middle node of doubly linklist to the top of the list

1 Answers  


Describe friend function & its advantages.

0 Answers   TCS,


Write a short code using c++ to print out all odd number from 1 to 100 using a for loop

0 Answers  


Categories