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
sir please send me bpcl previous question papers
What is stl in oop?
What is stl in c++ with example?
What do stl stand for?
How does an stl file work?
What are the symptoms of stl?
What two types of containers does the stl provide?
What does stl mean in slang?
What is stl language?
What are the different types of stl containers?
What is a list in c++ stl?
a program using one dimensional array that searches a number if it is found on the list of given input numbers given by the user and locate its exact location in the list.
How do you convert stl to steps?
What is meant by stl in c++?
What are the various types of stl containers?