I use below way to initialize an array of CandyBar structure, but compiler always says excess elements in struct initializer. I tried putting only one structure initializer in the array definition, it compiled, but the rest 2 elements of the array are null
What should I do?
struct CandyBar{
string brand;
float weight;
int calories;
};
int main(int argc, const char * argv[]) {
array<CandyBar, 3> ary_cb =
{
{"Mocha Munch", 2.3, 350},
{"Mocha Munch", 2.3, 350},
{"Mocha Munch", 2.3, 350}
};
return 0;
}