shekhar_shashi
asked on
C++ with VS 2008: Unable to overload << Operator
I am trying to overload the << operator.
I have a custom class called person.
I added this to person.h:
public:
.....
....
ostream &person::operator<<(ostrea m &stream, person &pers);
I added this to person.cpp
....
....
ostream &person::operator<<(ostrea m &stream, person &pers) {
return stream;
}
In the main function, I did the following.
person P4 = person("C", "C", 23);
cout << &P4 << " ";
I am getting an error that reads like:
error C2804: binary 'operator <<' has too many parameters.
I am using Visual Studio 2008.
Please help. Thanks in advance.
I have a custom class called person.
I added this to person.h:
public:
.....
....
ostream &person::operator<<(ostrea
I added this to person.cpp
....
....
ostream &person::operator<<(ostrea
return stream;
}
In the main function, I did the following.
person P4 = person("C", "C", 23);
cout << &P4 << " ";
I am getting an error that reads like:
error C2804: binary 'operator <<' has too many parameters.
I am using Visual Studio 2008.
Please help. Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Since you already answered my question, I am closing this post. But I am running into another problem. So I'll post the next problem shortly.
ASKER