For instance you may have a class definition with function prototypes in a .h file (I'll call it ***.h) that looks like this:
Code: Select all
class ***{
int x;
int y;
public:
***();
int Add();
};
Code: Select all
***::***(){
x = 5;
y = 10;
}
int ***::Add(){
return x + y;
}(Lets assume that the '+' operator has been overloaded for whatever 'T' becomes)
Code: Select all
template <class T>
class ***{
T x;
T y;
public:
***(T, T);
T Add();
}
template <class T>
***<T>::***(T one, T two){
x = one;
y = two;
}
template <class T>
T ***<T>::Add(){
return x + y;
}
Advertising