#include <string>
#include <iostream>
class Type {
public:
int x;
Type(int a)
{
x = a;
}
Type(const Type& type1)
{
std::cout << "copy" << std::endl;
}
};
Type Func()
{
Type s(1);
std::cout << &s << std::endl;
return s;
}
int main()
{
Type c = Func();
std::cout << &c << std::endl;
std::cout << c.x << std::endl;
system("pause");
}
C++ allocate memory for object in heap or stack? In Func, suppose "s" is allocated in stack, then why it don't be deconstructed? Why can i stiil call it in main(). I am very confused.