Write a note on class templates.
Answers
Answered by
0
A class template provides a specification for generating classes based on parameters.
They are generally used to implement containers.
Example:
template <class T>
class MyTemplate {
T element ;
public:
MyTemplate ( T arg ) { element= arg;}
T divideBy2 ( ) { return element/2 }
} ;
Similar questions
Chemistry,
6 months ago
Computer Science,
6 months ago
Math,
6 months ago
Psychology,
1 year ago
Art,
1 year ago
Math,
1 year ago