O
Old Wolf
"temporary" means an object without a name.
Yes there is. The call to monkey() returns a temporary variable of type int.
Then notemp is initialized from this temporary int, and then the temporary
int is destroyed.
Probably your compiler will use a register for the temporary int.
monkey() would assign 22 to this register, and then the calling function
would copy the value from that register into the memory location of notemp.
Of course, the compiler could optimise this out entirely, or in fact use
any other assembly instructions that it likes. That doesn't change
what is happening theoretically.
Yes there is. The call to monkey() returns a temporary variable of type int.
Then notemp is initialized from this temporary int, and then the temporary
int is destroyed.
Just check out assembly code created from compiler.
How and where do you think temporary variable is created in
called function?
Probably your compiler will use a register for the temporary int.
monkey() would assign 22 to this register, and then the calling function
would copy the value from that register into the memory location of notemp.
Of course, the compiler could optimise this out entirely, or in fact use
any other assembly instructions that it likes. That doesn't change
what is happening theoretically.