Member Function Templates

After declaring a templated class, define member functions as function templates. For example:

template<class T, int i> class MyStack
{
    T*  pStack;
    T StackBuffer[i];
    int cItems = i * sizeof(T);
public: 
    MyStack( void );
    void push( const T item );
    T& pop( void );
};

template< class T, int i > MyStack< T, i >::MyStack( void )
{ ... } ;
template< class T, int i > void MyStack< T, i >::push( const T item )
{ ... } ;
template< class T, int i > T& MyStack< T, i >::pop( void )
{ ... } ;

Note that the definition of the constructor function does not include the template argument list twice.