[Solved] What happens to an object during a pre-increment operation?


The pre-increment operator method returns a new object. Which invokes a constructor and, shortly later, destructor.

Cls operator++(){i++; return *this;}
^^^  return by value.
     Means you need to be able to copy construct "Cls"

Note you would normally write this as:

Cls& operator++(){i++; return *this;}
  ^^^   To return the object by reference (and thus avoid construction/destruction).

You should also note that if you increase the optimization level you are using then the “BC” are likely to disappear as the compiler can easily “elide” the copy operation as an optimization.

solved What happens to an object during a pre-increment operation?