When creating a new instance of a MyClass
as an argument to a function like so:
class MyClass
{
MyClass(int a);
};
myFunction(MyClass(42))
In section 12.2, Temporary Objects, clause 3, the ANSI/ISO C standard states: "... Temporary objects are destroyed as the last step in evaluating the full-expression that (lexically) contains the point where they were created."
This is closely related to the concept of Sequence Points. When a sequence point is reached, all side-effects of expressions are guaranteed to have taken place.