For case 1 the A
object instance is created on the heap, while the location of the variable c
depends on if it’s a global, member or local variable.
[Note: Question edited, case 2 totally different]For case 2 no object is created, as it is a function declaration.
For case 2, the location of c
depends on where it’s declared. If it’s a global variable, then it’s placed in the global data segment. If it’s an argument or a local variable, it’s placed on the stack, if it’s a member variable it’s placed wherever the containing object is placed.
In case 3 a temporary variable is created by the compiler wherever it wants, most likely the stack though.
It’s important to note that the C specification actually doesn’t specify where variables are actually placed, the specification only places constraints on the scope, life-time and linkage of variables, like arguments and local variables only being available inside the function (or nested block) they were declared in.
1
solved class object initialization in c++