Can Templates Have prototypes ?
If yes,
Help with the declaration
addicted
Junior Poster in Training
57 posts since Mar 2007
Reputation Points: 10
Solved Threads: 0
If yes,
Help with the declaration
template< typename T > inline void swap( T& a, T& b ) ; // declaration (function)
template< typename T, size_t N > struct array ; // declaration (class)
// definition of function
template< typename T > void swap( T& a, T& b )
{ T temp(a) ; a=b ; b=temp ; }
// definition of class
template< typename T, size_t N > struct array
{
T& operator[] ( size_t i )
{
if( i >= N ) throw "array bound exceeded!" ;
return a[i] ;
}
const T& operator[] ( size_t i ) const
{
if( i >= N ) throw "array bound exceeded!" ;
return a[i] ;
}
private: T a[N] ;
};
vijayan121
Posting Virtuoso
1,606 posts since Dec 2006
Reputation Points: 1,159
Solved Threads: 287