临时文件不应该A(3)
在“这里”被打印之前被销毁吗?
#include <iostream>
struct A
{
int a;
A() { std::cout << "A()" << std::endl; }
A(int a) : a(a) { std::cout << "A(" << a << ")" << std::endl; }
~A() { std::cout << "~A() " << a << '\n'; }
};
int main()
{
A a[2] = { A(1), A(2) }, A(3);
std::cout << "Here" << '\n';
}
输出:
A(1)
A(2)
A(3)
Here
~A() 3
~A() 2
~A() 1