What is a template?

Answer Posted / ravinandan

Template is used for generic programming. In other words
when you want to write a function or a class type
independent, go for templates.

template<class T>
void fun(T x, T y); // Is a Template function

template<typename T>
class abc{
T m;
}; // Is a Class Template

template<class T>
class abc{
T m;
}; // Is a Class Template

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we use oops?

591


How do you achieve polymorphism?

609


What is class and example?

567


Explain virtual inheritance?

682


How long to learn object oriented programming?

561






What is object in oop?

679


class type to basic type conversion

1833


What is polymorphism in oops?

556


How oops is better than procedural?

583


What is the problem with multiple inheritance?

582


Can static class have constructor?

582


What is protected in oop?

602


What does no cap mean?

590


What is multilevel inheritance explain with example?

623


What is the difference between static polymorphism and dynamic polymorphism?

579