If yes,
Help with the declaration

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] ;
};
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.