friend operator


 
Thread Tools Search this Thread
Top Forums Programming friend operator
# 1  
Old 04-25-2006
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
# 2  
Old 06-10-2008
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

3 More Discussions You Might Find Interesting

1. Programming

What are Friend Functions in C++?

Hey C++ masters! I am a beginner in C++ and learning about it but have some doubts about Friend Functions. Anyone describe C++ Friend Functions? (1 Reply)
Discussion started by: ggiwebsinfo
1 Replies

2. UNIX for Dummies Questions & Answers

welcome YOUR NEW FRIEND RETO

Hello Every One Iam Your New Friend Reto .iam New In Unix Let Me Say That Iam Zero . And I Wish That You All Can Help Me With It By Your Help I Will Get To The Top Your New Friend Reto From Iraq Thank You All (0 Replies)
Discussion started by: retolop
0 Replies

3. UNIX Desktop Questions & Answers

Find a friend

I am unix beginner, aspiration learning with unix. i want get help for unix .I have a dream that i become unix master-hand. I wish get your assist for unix or net. (2 Replies)
Discussion started by: Yeliu
2 Replies
Login or Register to Ask a Question