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?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Do class declarations end with a semicolon?

1088


what are Operators and explain with an example?

1167


How is computer programming useful in real life?

1071


Do we have to use initialization list in spite of the assignment in constructors?

1007


Explain the isa and hasa class relationships. How would you implement each?

1132


What is the header file for setw?

1135


Why c++ is better than c language?

1020


Are strings mutable in c++?

1139


Why namespace is used in c++?

1073


What is an associative container in c++?

1072


How to tokenize a string in c++?

1065


What is the latest c++ standard?

1152


program explaining feautures of c++

2443


Write a program for Divide a number with 2 and Print the output ( NOTE: Check for divide by zero error).

1113


When should we use container classes instead of arrays?

1029