-
June 1st, 2012, 12:06 AM
#1
-
June 1st, 2012, 01:06 AM
#2
Re: member function of one class can be friend function of another class
Originally Posted by Tanushreeagr
M...
[ In the above program : friend void car: isplay(scooter); Is this the correct way to make member function of one class , friend function of another class.?]
1. please, use Code tags while posting code snippets.
2. Did you try to compile this code? What does compiler say you?
Victor Nijegorodov
-
June 1st, 2012, 02:37 AM
#3
Re: member function of one class can be friend function of another class
Originally Posted by VictorN
1. please, use Code tags while posting code snippets.
2. Did you try to compile this code? What does compiler say you?
I have added necessary code.
TANUSHREE-AGRAWAL...
-
June 1st, 2012, 02:39 AM
#4
Re: member function of one class can be friend function of another class
No you haven't. The post still lacks code tags [code]Properly indented code here[/code]
-
June 2nd, 2012, 02:45 PM
#5
Re: member function of one class can be friend function of another class
I suspect that the correct way to solve your real problem (not the one stated here - that is just due to the way you are approaching this) is to have a base class (e.g. vehicle) which contains the speed and color fields, and the method display. Then derive car and scooter classes from this.
-
June 3rd, 2012, 06:12 AM
#6
Re: member function of one class can be friend function of another class
Please stop using the 'friend' keyword. Wipe it from your memory. As soon ans you need the 'friend' keyword, your design is wrong.
-
June 3rd, 2012, 04:11 PM
#7
Re: member function of one class can be friend function of another class
As soon ans you need the 'friend' keyword, your design is wrong.
Untrue as any excessively categorical statement. An advice to use 'friend' as rare as possible would be more correct.
Best regards,
Igor
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|