-
Make this class declaration a template:
template < typename ValueT >
class Stack {
public:
void push( ValueT item );
};
-
ValueT is the template parameter, standing in for the type.
|
-
When the user declares
Stack< int > stack_i;
-
Template is instantiated for int, that is,
ValueT becomes int:
// Pseudocode:
template < typename ValueT=int >
class Stack {
public:
void push( int item );
};
|