a++
alone would suffice, without the assignment. The ++
operator acts on its operand "on the spot", meaning you don't need to do any assigning. And a = a++
is undefined behavior, so you don't want to do that.
Try:
Class test
{
public:
int a=10;
void operator ++(int)
{
a++;
cout<<a;
}
}
musicfreak
2010-10-04 04:18:21