J
jois.de.vivre
Hi, I'm having some trouble overloading the << operator. I have the
following, very simple code:
#include <iostream>
using namespace std;
class test
{
private:
int val;
public:
test():val(0){}
const int GetVal() const{
return val;
}
ostream& operator<< (ostream& os , test& a) {
os << a.GetVal();
return os;
}
};
//------End Sample Code
I get the following error during compile. What does this error mean?
error: 'std:stream& test:perator<<(std:stream&, test&)' must
take exactly one argument
I want to do something like
test MyTest;
cout << test << endl;
Thanks
following, very simple code:
#include <iostream>
using namespace std;
class test
{
private:
int val;
public:
test():val(0){}
const int GetVal() const{
return val;
}
ostream& operator<< (ostream& os , test& a) {
os << a.GetVal();
return os;
}
};
//------End Sample Code
I get the following error during compile. What does this error mean?
error: 'std:stream& test:perator<<(std:stream&, test&)' must
take exactly one argument
I want to do something like
test MyTest;
cout << test << endl;
Thanks