B
Brett Irving
Hi I keep having problems with trying to overload the << operator,
the compiler will not let me define it.
the code looks like
#ifndef __MYARRAY_H__
#define __MYARRAY_H__
#include <iostream>
..
..
..
..
};
ostream & operator<<(ostream &o, MyArray& m)
{
return m(o);
}
#endif
It wont work if I put it inside or out of the #endif
The error that the compiler keeps giving me is this.
ld: fatal: symbol `operator<<(std::basic_ostream<char,
std::char_traits<char> >&, MyArray&)' is multiply defined:
(file MyArrayMain.o and file MyArray.o);
ld: fatal: File processing errors. No output written to myarray
collect2: ld returned 1 exit status
Please help.
thanks a lot
the compiler will not let me define it.
the code looks like
#ifndef __MYARRAY_H__
#define __MYARRAY_H__
#include <iostream>
..
..
..
..
};
ostream & operator<<(ostream &o, MyArray& m)
{
return m(o);
}
#endif
It wont work if I put it inside or out of the #endif
The error that the compiler keeps giving me is this.
ld: fatal: symbol `operator<<(std::basic_ostream<char,
std::char_traits<char> >&, MyArray&)' is multiply defined:
(file MyArrayMain.o and file MyArray.o);
ld: fatal: File processing errors. No output written to myarray
collect2: ld returned 1 exit status
Please help.
thanks a lot