In what cases using of a 'template' is a better approach
then using of a 'base class'?
Answer Posted / atul jawale
Template is a better approach than using of a base class if:
1. Multiple copies of code for different data types with
the same logic.
2. If a set of functions or classes have the same
functionality for different data types
Then, a class becomes good candidates for being written as
Templates.
One good area where this C++ Class Templates are suited
can be container classes. Very famous examples for these
container classes will be the STL classes like vector, list
etc., Once code is written as a C++ class template, it can
support all data types.
Though very useful, It is advisable to write a class as a
template after getting a good hands-on experience on the
logic.
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
i wanted to know about questions about c,c++ , which is required for placements.... im a fresher
Can we use stl in coding interviews?
What do stl stand for?
Is stl part of c++ standard?
Why should a c++ programmer be interested in stl?
help me i need a c++ program which takes sequesnce of characters and outputed sequence of their token taypes, work same compiler in lexical analysis phase
Do you like to Submit Questions in Bulk under Same Category?? Then use our Bulk ListerDo you like to Submit Questions in Bulk under Same Category?? Then use our Bulk Lister
What is the stl, standard template library?
What are the various types of stl containers?
Describe how to safeguard a system through acquisition of an antivirus Program and systematic backup.
What is stl stack?
Define stl.
What is a stl vector?
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.
Is stl open source?