|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 ! ![]() |
|
#2
|
||||
|
||||
|
I'm guessing a fair bit, as your sample is incomplete.
I'm guessing this is actually embedded in a class something like' class Foo { public: 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; class DiveLogPage { public: 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. |
|
#3
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > binary 'operator <<' has too many parameters |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|