PDA

View Full Version : Overloading prefix operator


yawningdog
07-08-2002, 08:40 PM
Is this legal on the g++ compiler?

# include <iostream.h>

class Counter
{
public:
Counter();
~Counter(){};
int GetItsVal()const {return itsVal};
void SetItsVal(int x) {itsVal=x};
void Increment() {++itsVal;}
void operator++ () {++itsVal;}
private:
int itsVal
};

I'm getting some weird errors when I try to compile.

Arowa704
08-08-2003, 07:19 PM
Sorry, posted my question here by accident and I can't delete it. I'm a newbie :)