考虑代码段
main()
{
cout << "Hello";
}
不触及上面的代码段打印
您好
你好
再见
答案 0 :(得分:4)
#include <iostream>
using namespace std;
struct A
{
A() { cout << "Hi" << endl; }
~A() { cout << endl << "Bye"; }
};
A a;
main()
{
cout << "Hello";
}
答案 1 :(得分:1)
#include <iostream>
using namespace std;
struct A
{
A() { cout << "Hi" << endl; }
~A() { cout << "\nBye" << endl; }
};
A a;
int
// untouched part :)
main()
{
cout << "Hello";
}
输出
Hi
Hello
Bye