哦,C ++专家们,我寻求您的智慧。与我说标准话,并告诉我C ++是否保证以下程序:
#include <iostream>
using namespace std;
struct A
{
A() { cout << "A::A" << endl; }
~A() { cout << "A::~" << endl; }
};
struct B
{
B() { cout << "B::B" << endl; }
~B() { cout << "B::~" << endl; }
};
struct C
{
C() { cout << "C::C" << endl; }
~C() { cout << "C::~" << endl; }
};
struct Aggregate
{
A a;
B b;
C c;
};
int main()
{
Aggregate a;
return 0;
}
将永远产生
A::A
B::B
C::C
C::~
B::~
A::~
换句话说,是否保证成员按声明顺序初始化并以相反的顺序销毁?
慕雪6442864
大话西游666
POPMUISE
相关分类