A few things to note When you are overloading operators in C++ there are some things to know, for example ++ you caneither do a preincrement
++i
or a post increment
i++
in order to tell the compiler which you are overloading you'll need to have no parameters or an int in the signature
A operator++(int)
is overloading the post incremennt,
A& operator++()
overloads pre increment
In C++ an object's desctructor is called in two cases
You call delete on a pointer to an object you allocated using new
A* = new A(); //constructor is called delete(A);//destructor is called
You leave context for an object created on the stack
if(something) { A a(); ... } //here a's destructor is called because a no longer exists
Notice in your code how some operators return a copy, others return a reference.
A operator++(int)
this function is returning a copy. This means that when you call this particular function the constructor is being called once inside the function for the new A that is being called and then again when you return from the function as a copy of the object pointed to by b is being copied.
You can find some infromation on operator precedence [here] (http://en.cppreference.com/w/cpp/language/operator_precedence)
I notice some people are tellign you it's useless to learn from code like this. I agree that coding in this way is pretty bad, but it can teach you a lot about how constructors/destructors, heap/stack and operators work in C++. There are probably better ways of learning, this seems pretty 'mid-term examy' to me.