支持聚合初始化
下面的示例在 Visual C++ .NET 2003 中工作在该标准上指定:
// support_aggregate_initialization1.cpp
struct NotAgg
{
NotAgg(int)
{
}
};
struct Agg
{
NotAgg mem;
};
int main()
{
Agg anAggregate = { NotAgg(1) };
}
下面的示例在 Visual C++ .NET 2003 中工作在该标准上指定:
// support_aggregate_initialization2.cpp
// compile with: /EHsc
#include <string>
#include <iostream>
using namespace std;
struct MyStruct
{
string strA;
string strB;
} myStrings[2] = { {"a", "b"}, {"c", "d"} };
int main()
{
cout << myStrings[0].strB << endl;
}