July 16th, 2003, 08:26 PM
binary 'operator <<' has too many parameters
Can anyone tell me what is wrong with these piece of code?
ostream& operator<<(ostream& Out, const DiveLogPage& toWrite)
Thanks ! :)
July 17th, 2003, 09:00 AM
I'm guessing a fair bit, as your sample is incomplete.
I'm guessing this is actually embedded in a class something like'
ostream& operator<<(ostream& Out, const DiveLogPage& toWrite) ;
which actually declares operator<< as a non-static member function of class Foo. As a non-static member function, this means the operator will accept an implicit "this" pointer i.e. the function effectively has three arguments.
As to what you're trying to do, you probably intended something like;
friend ostream& operator<<(ostream& Out, const DiveLogPage& toWrite) ;
A friend function is not actually a member function, so does not have the hidden "this" pointer passed to it.
July 19th, 2003, 10:23 PM
I think when you put a binary operator overload function inside a class it, in fact, only takes one argument.
Try declaring this function outside any classes.