(15+n2); not working where n2 is class

(15+n2); not working where n2 is class

Post by iceColdFir » Sun, 29 May 2005 20:46:20


I created a simple c++ program to overload operators,
class Number {...}

now when I use the class like,,,
Number n1(15);
Number n2(5);

I get error as 'Reverse iterator' in line (15+n2)...

Kindly explain what the issue is and what is reverse iterator...

Thanksin advance..

(15+n2); not working where n2 is class

Post by John Carso » Sun, 29 May 2005 21:30:42

You should supply the code, but my guess is that you have made operator+() a
member function, which means you can only use it when a Number object is on
the left hand side of the + sign. If you want a number object on the right
hand side, you need to make operator+() a non-member (and a friend if any
access to private members is required). You need to overload this operator
for the

(Number, int)
(int, Number)
(Number, Number)


John Carson