Error when overloading << in template

A

atomik.fungus

Hi, as many others im making my own matrix class, but the compiler is
giving me a lot of errors related to the friend functions which
overload >> and <<.I've looked around and no one seems to get the same
error. Here is the code of the class template< class T > class Matrix
{ friend ostream &operator << <>( ostream &, const Matrix< T >
& ); friend istream &operator >> <>( istream &, Matrix< T > &
); public: Matrix( int = 3, int = 3 ); Matrix( const
Matrix< T > & ); ~Matrix(); private: int r_size,
c_size; T **ptr; }; and here the definition for ostream
&operator << and istream &operator >> //cout template< class T >
ostream &operator << ( ostream &output, const Matrix< T > &m ) {
int i, j; for( i = 0; i < m.r_size; i++ ) {
for( j = 0; j < m.c_size; j++ ) {
output << m.ptr[ i ][ j ] << " "; }
output << endl; } return output; } //cin template<
class T > istream &operator >> ( istream &input, Matrix< T > &m ) {
int i, j; for( i = 0; i < m.r_size; i++ ) {
cout << "Introduzca los elementos de la fila " << i << " separados por
espacios\n"; for( j = 0; j < m.c_size; j++ )
input >> m.ptr[ i ][ j ]; } return
input; } Errors given by the compiler error: el id de plantilla
'operator<< <>' para 'std::basic_ostream<char,
std::char_traits<char> >& operator<<(std::basic_ostream<char,
std::char_traits<char> >&, const Matrix<int>&)' no coincide con
ninguna declaración de plantilla error: el id de plantilla
'operator>><>' para 'std::basic_istream<char,
std::char_traits<char> >& operator>>(std::basic_istream<char,
std::char_traits<char> >&, Matrix<int>&)' no coincide con ninguna
declaración de plantilla Im spanish so maybe a small spanish class
will be helpfull for most readers of this group plantilla == template
no coincide con ninguna declaracion de == does not coincide with any
declaration of Also when a try to use the overloaded operators in main
a get another error which tells that the private members of class
Matrix are private in that context. Thanks
 
A

atomik.fungus

Sorry its the first time i post in google groups and something went
wrong.

If an administrator sees this please remove the post, and ill try to
make it better next time
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,185
Latest member
GluceaReviews

Latest Threads

Top