what is the use of templates?

Answer Posted / aboelella

Template is used to optimize code
instead of implementing the same code for multiple data
types, template works as a way to declare classes and
functions and then to be implemented with different data types

It is dependent on the data structure used to substitute the
template

Is This Answer Correct ?    18 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what are the decision making statements in C++? Explain if statement with an example?

749


What is meaning of in c++?

762


what is the difference between overloading & overriding? give example.

670


Which should be more useful: the protected and public virtuals?

681


Is c++ a pure oop language?

699






What should main() return in c and c++?

616


How a macro differs from a template?

766


I was a c++ code and was asked to find out the bug in that. The bug was that he declared an object locally in a function and tried to return the pointer to that object. Since the object is local to the function, it no more exists after returning from the function. The pointer, therefore, is invalid outside.

695


What is a constant reference?

705


What is the difference between structure and class?

654


What is the role of static keyword for a class member variable?

727


What are literals in C++?

676


In the derived class, which data member of the base class are visible?

740


What are the types of array in c++?

697


When should we use container classes instead of arrays?

675