struct FoodRec
{
string name;
int hsize;
string *healthy;
};
现在假设我想创建一个struct food rec的数组,并希望将数据存储到内部的动态数组中,以下语法是否合适;
Foodrec f[5];
int n=5;
f[0].healthy=new string[n];
f[0].healthy[0]="Fire";
f[1].healthy=new string[n+1];
f[1].healthy[0]="Water";