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
How is stl different from c++ standard library?
What are the components of stl?
Is string part of stl?
Explain stl.
draw a flowchart that accepts two numbers and checks if the first is divisible by the second.
How connect plc and pc through software
Name the different types of stl containers.
write a program that will accept a number and print.its equivalent in words the maximum input number is 9999
What are the various types of stl containers?
To modify an, existing worksheet. What steps are involved for: 1. Inserting and deleting rows and columns. 2. Printing cell formulas 3Jld displayed values 3. Using the page setup command
how to use C++?
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
what is template and type convertion
Why should a c++ programmer be interested in stl?
What are stl algorithms?