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

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; }

1894


How do I convert a stl file?

566


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

1859


What is a stl vector?

628


Explain stl.

905






write a program to convert a decimal number in to its equivalent binary number?

2084


What is stl stack?

665


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

1646


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

1664


Why should a c++ programmer be interested in stl?

645


how can u do connectivity in c++ language? plz send me connectivity code in c++ ?

1895


What are the different types of stl containers?

652


What is stl stand for?

742


What are the various types of stl containers?

733


What does stl stand for in basketball?

643