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 programming language should I learn first?

1152


Which programming language's unsatisfactory performance led to the discovery of c++?

1398


Is c++ vector dynamic?

1213


Explain unexpected() function?

1163


What is a storage class?

1374


How does java differ from c and c++?

1042


What is abstract class in c++?

1137


What is the limitation of cin while taking input for character array?

2161


Can we use this pointer inside static member function?

1117


What is a c++ map?

1515


What is the difference between interpreters and compilers?

1272


Can constructor be private in c++?

1087


What are the advantages of early binding?

1117


Can turbo c++ run c program?

1148


Explain about vectors in c ++?

1082