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

What are the advantages of using friend classes?

0 Answers  


Write a recursive program to calculate factorial in c++.

0 Answers  


C is to C++ as 1 is to a) What the heck b) 2 c) 10

0 Answers  


How would you implement a substr() function that extracts a sub string from a given string?

0 Answers  


Which bit wise operator is suitable for checking whether a particular bit is on or off?

0 Answers  


What are the advantages and disadvantages of using inline and const?

2 Answers   Polaris, TCS, Zimmer Biomet,


What is meant by entry controlled loop? What all C++ loops are exit controlled?

0 Answers   TCS,


Can you write a function similar to printf()?

0 Answers  


Will the inline function be compiled as the inline function always? Justify.

1 Answers  


What does asterisk mean in c++?

0 Answers  


What is the Difference between "vector" and "array"?

15 Answers   Covansys, Gambit, TCS, Wipro,


What do you mean by friend class & friend function in c++?

0 Answers  


Categories