C++ Postfix Operator Strange Behaviour in BorlandC++

55 Views Asked by At

Overloading problem.

I have tried to overload Postfix++ operator in a class then I saw a strange behaviour whenever I try to do this

cout << oldValue <<" "<< oldValue++;

From the above cose the expected output should be the same, But it's not

The output is as following.

(oldValue) incremented by 1

And space

And oldValue

Another example

I thought I have some sort of error in the overloading.

I tried this code

int x = 0;

cout << x << " " << x++ ;

The output is

1 0

But it should be 0 0

I traced the code line by line but found nothing strange.

I seek a clarification for this strange behavior.

0

There are 0 best solutions below