In what cases using of a 'template' is a better approach
then using of a 'base class'?

Answer Posted / nishikant sahu

You can judge the need of Template and base class based on
following rule of thumb..
When operation(Method) doesn't affect on changing the data
type, use template.for ex when you want to write the stack
class of different data TYPE(int, bool,flaot) PUSH & POP
method doesn't affect on changing the data TYPE so in this
case you have to use TEMPLATE instead of Inheritance.
When operation(Method) does affect on changing the data
type, use Inheritance(base class).

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is stl in c++ with example?

833


How is stl different from c++ standard library?

950


What two types of containers does the stl provide?

746


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.

1580


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

2077


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

1851


What is a standard template library (stl)? What are the various types of stl containers?

895


sir please send me bpcl previous question papers

2138


i wanted to know about questions about c,c++ , which is required for placements.... im a fresher

1901


Can we use stl in coding interviews?

1535


Who wrote stl?

879


Is stl part of c++ standard?

812


How do you convert stl to steps?

825


How does an stl file work?

855


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.

2169