When is a template a better solution than a base class?
Answer / neelkamal yadav
When you are designing a generic class to contain or otherwise manage objects of other types, when the format and behavior of those other types are unimportant to their containment or management, and particularly when those other types are unknown (thus, the genericity) to the designer of the container or manager class.
Prior to templates, you had to use inheritance; your design might include a generic List container class and an application-specific Employee class. To put employees in a list, a ListedEmployee class is multiply derived (contrived) from the Employee and List classes. These solutions were unwieldy and error-prone. Templates solved that problem.
| Is This Answer Correct ? | 0 Yes | 0 No |
Write a program in C++ for Fibonacci series
0 Answers Axtria, ITC Indian Tobacco Company,
Can c++ do everything c can?
Difference between overloaded functions and overridden functions
Can you use the function fprintf() to display the output on the screen?
What is object file? How can you access object file?
why is iostream::eof inside a loop condition considered wrong?
What does the nocreate and noreplace flag ensure when they are used for opening a file?
What are friend functions?
What is & in c++ function?
I want explanation for this assignment: how to connect mysql database using c/c++,please explain this detailly?
How much do c++ programmers make?
How does work in c++?