C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 16th, 2003, 09:26 PM
Davis Davis is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 6 Davis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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 !

Reply With Quote
  #2  
Old July 17th, 2003, 10:00 AM
grumpy's Avatar
grumpy grumpy is offline
Left due to despotic ad-min
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2003
Posts: 1,042 grumpy User rank is Corporal (100 - 500 Reputation Level)grumpy User rank is Corporal (100 - 500 Reputation Level)grumpy User rank is Corporal (100 - 500 Reputation Level)grumpy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 53 m 47 sec
Reputation Power: 8
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.

Reply With Quote
  #3  
Old July 19th, 2003, 11:23 PM
slider slider is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 3 slider User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > binary 'operator <<' has too many parameters


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT