【发布时间】:2011-04-22 19:29:12
【问题描述】:
以下insert 有效吗?我的问题的原因是身体中有另一个结构,其中还有另一个结构(数组)。所有变量a、b、c、x、y 和 z 都是次要的,只是为了支持我的问题。
提前致谢。
struct S_A
{
int a;
float b;
char c;
// ...
S_B my_double_nested_structure;
};
struct S_B
{
int x;
float y;
char z;
// .. .
char array1[2];
};
typedef std::map<int, S_A> myAMapType;
S_A nestedStruct;
nestedStruct.a = 5;
nestedStruct.b = 5.9;
nestedStruct.c = 'A';
nestedStruct.my_double_nested_structure.x = 4;
nestedStruct.my_double_nested_structure.y = 8.9;
nestedStruct.my_double_nested_structure.z = 'B';
nestedStruct.my_double_nested_structure.array1[0] = 'B';
nestedStruct.my_double_nested_structure.array1[1] = 'C';
main()
{
myAMapType finalMap;
finalMap.insert(std::pair<int, S_A>(3, nestedStruct);
}
【问题讨论】:
-
要格式化代码,要么缩进四个空格,要么选择它并点击
{}按钮。 -
@seymoure:谢谢,会的
标签: c++ insert nested structure stdmap