The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
welcome YOUR NEW FRIEND RETO retolop UNIX for Dummies Questions & Answers 0 06-13-2007 12:30 AM
Find a friend Yeliu UNIX Desktop for Dummies Questions & Answers 2 09-18-2002 08:55 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 04-25-2006
nik nik is offline
Registered User
 

Join Date: Mar 2004
Location: Germany
Posts: 6
friend operator

Hello,

I have a problem by compiling a class with the following friend function in Header file:

class X{

private:
......

protected:
.......

public:

friend ostream& operator<<(ostream& target, const PARA_DSC& para);


};


the compiler output is:

"X.hxx", line 346: Warning (Anachronism): Class friends require an explicit "class".
"X.hxx", line 346: Error: "," expected instead of "&".
1 Error(s) and 1 Warning(s) detected.
*** Error code 1

Has anybody an idea, where the problem coud be?


Greetings

nik
Reply With Quote
Forum Sponsor
  #2  
Old 06-10-2008
Registered User
 

Join Date: Jun 2008
Posts: 1
I think you need to put the "friend" after the return value of the operator. I.e.:

ostream& friend operator<<(ostream& target, const PARA_DSC& para);

If "friend" is the first token, then it expects the declaration of a friend class.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:16 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0