When is a template better solution than a base class??

Answers were Sorted based on User's Feedback



When is a template better solution than a base class??..

Answer / mayank kumar

as template is in form of generic class and generic
function so here the class and function works for all. also
in template we can change the data type of function
parameter as well as of the data member present in class.

Is This Answer Correct ?    7 Yes 0 No

When is a template better solution than a base class??..

Answer / faruk

1.when you are designing a generic class to contain or otherwise manage objects of other types.
2.when the format and behaviour of those other types are unimportant to their containment or management.
3.particularly when those other types are unknown.

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More C++ General Interview Questions

What do you mean by abstraction. Explain your answer?

5 Answers  


Explain the concept of dynamic allocation of memory?

0 Answers  


Is python better than c++?

0 Answers  


What are stacks?

0 Answers  


How to stop conversions among objects?

5 Answers   Symphony,






What are multiple inheritances (virtual inheritance)? What are its advantages and disadvantages?

0 Answers  


simple c++ program for "abcde123ba" convert "ab321edcba" with out using string

5 Answers  


Write a C++ program which will compute the volume of a sphere or a cylinder after prompting the user to type the first character for the shape name.

0 Answers   An-Najah National University,


What is cout flush?

0 Answers  


Write a c++ code that will calculate the roots of a quadratic equation a2+ bx+c=0 Hint: d = sqrt (b2-4ac), and the roots are: x1 = (€“b + d)/2a and x2 = (€“b €“ d)/2a (use sqrt function from cmath.h )?

0 Answers   Maxobiz,


What is the difference between the parameter to a template and the parameter to a function?

0 Answers  


What is a node class in c++?

0 Answers  


Categories