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 is an Iterator class?

1 Answers  


Why do we need constructors in c++?

0 Answers  


How do you clear a map in c++?

0 Answers  


What is new in c++?

0 Answers  


What is c++ hash?

0 Answers  






What are c++ variables?

0 Answers  


What is a forward referencing and when should it be used?

0 Answers  


What data structure is fastest, on average, for retrieving data: a) Binary Tree b) Hash Table c) Stack

0 Answers  


What are the rules for naming an identifier?

0 Answers  


What flag means?

0 Answers  


Write a program and call it sortcheck.cpp which receives 10 numbers from input and checks whether these numbers are in ascending order or not. You are not allowed to use arrays. You should not define more than three variables

2 Answers   BirlaSoft, Crayonz,


what is the order of initialization for data?

10 Answers   Amazon, TCS, Wipro,


Categories