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] ;
};
Reputation Points: 1159
Solved Threads: 285
Posting Virtuoso
Offline 1,606 posts
since Dec 2006