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

What is a c++ object?

1247


Can class objects be passed as function arguments?

1112


Write a program which uses functions like strcmp(), strcpy()? etc

1150


What is struct c++?

1049


Does c++ have foreach?

1125


How static variables and local variablesare similar and dissimilar?

1093


Is c# written in c++?

1029


What is doubly linked list in c++?

1124


how to connect with oracle 9i with server in socket program in c/c++

2395


What is c++ try block?

1088


What is std :: flush?

1126


Are iterators pointers?

1203


Is c++ a software?

1242


What is general format for a prototype?

1090


Why do we use iterators?

1130