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...

When is a template a better solution than a base class?

Answer Posted / neelkamal yadav

When you are designing a generic class to contain or otherwise manage objects of other types, when the format and behavior of those other types are unimportant to their containment or management, and particularly when those other types are unknown (thus, the genericity) to the designer of the container or manager class.

Prior to templates, you had to use inheritance; your design might include a generic List container class and an application-specific Employee class. To put employees in a list, a ListedEmployee class is multiply derived (contrived) from the Employee and List classes. These solutions were unwieldy and error-prone. Templates solved that problem.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is arr and &arr are same expression for an array?

1043


Is map sorted c++?

992


What is the role of C++ shorthand's?

1266


What is constructor in C++?

1071


What is do..while loops structure?

1132


How does java differ from c and c++?

976


What is a driver program?

1092


What things would you remember while making an interface?

994


Difference between delete and free.

1068


Define pointers?

1033


Describe public access specifiers?

1100


What is problem with overriding functions?

1049


How is modularity introduced in C++?

1197


What is insertion sorting?

1094


Why do we use classes in c++?

1044