If i have a function like Qpoint foo()
then I write: Qpoint g=foo()
after executing the second line I want to know if the qpoint returned in the function will exist in memory like a pointer (until program is closed or a delete statement) or its deleted like a native data type.
Thank you very much!
Hi and welcome to devnet,
gwill live as long as the function containing it and long if it's a class member.
Thank you very much!. So, the object returned in the function (not g) will die too. Isnt it?
Yes, if g wasn't there to get the copy it would already have been destroyed.
Are you studying stack vs heap memory ?