friend operator function
I want to write it with friend operator function.this program gives two errors.what's the problem?
Error 1 error C2678: binary '+' : no operator found which takes a left-hand operand of type 'int' (or there is no acceptable conversion)
IntelliSense: no operator "+" matches these operands
using namespace std;
friend int operator + (rect ob,int j);
int operator + (rect ob,int j)
Also I have a question... :)
What is "friend" attribute? And usage?
Does noone know about this?
Try reversing function args lines 10 and 36. You seek int+rect not rect+int (which you could do with a member function).
@JM: The function (operator+) must be a friend of the rect class so it can refer to the private member s on line 38.
If I want to write it with friend How Should I write?
In this program ,I think friend function is true.
I had not read your talking well .It is working now.
You're welcome. Glad you got it. Sorry if my answer was unclear.
Topic archived. No new replies allowed.