Possible Duplicate:
Operator Overloading in C++ as int + obj
I have a class A
with an overloaded operator+
. My problem is that I wish to be able to use summation in the two following ways.
A a;
a + 5;
and
5 + a;
How do I overload +
to be able to do this? I am aware that we can overload ++
to perform both post and pre increment (++x
and x++
), so how can I simulate the above ability as well?