I am trying to allocate a dynamic string array in the following way and I get an error:
struct Test
{
std::string producer[];
std::string golden[];
};
Test test1 =
{
{"producer1", "producer2"} ,
{"golden1" , "golden2"}
};
The error i get is that there are too many initializers for std::string[0],
but if I get off the array part it works:
struct Test
{
std::string producer;
std::string golden;
};
Test test1 =
{
"producer1" ,
"golden1"
};
Thanks in advance!
std::string producer[];You cannot declare an array without saying how many elements is should contain.string[], you'd have to define the object as astring*, not astring[]. The only places where and actualstring[]would be legal is as anextern, or as a reference parameter to a function (but that's a bit tricky, since you cannot then pass the function an array whose size is known).