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


Please Help Members By Posting Answers For Below Questions

Describe the My Computer and My Documents folders; identify the elements that are present in every Window.

1845


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

1873


What is a standard template library (stl)?

632


Describe how to safeguard a system through acquisition of an antivirus Program and systematic backup.

1636


Is string part of stl?

668






In what scenario does the Logical file and Physical file being used?

2313


Explain stl.

894


What is the use of stl?

627


please visit this site you'll find my question this is my homework please answer it if you can http://easyscience.org/ib/lofiversion/index.php/t36168.html

1768


Is there any error below, its a code to delete all entires from a map #include #include iostream.h int main() { int i =0; map TestMap; while(i<3) { TesMap.insert(TestMap::value_type(i,Test)); i++; } typedef map :: iterator mapIter =TestMap.begin(); if(mapIter!=TestMap.end()) { TestMap.erase(mapItrer); ++mapIter; } return 0; }

1877


What is a stl vector?

619


How stl is different from the c++ standard library?

633


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

1965


Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.

2082


What is meant by stl in c++?

644