I have a struct in my header file
struct Foo{
timeval t;
struct Bar b;
}
and i also have another one for Bar in the same header file, and I have declared a class in the header file as well.
class Layer{
public:
...
...
private:
struct Foo myarray[];
}
I want to declare an array of Foo in my header file and initialize it in my class constructor
Layer::Layer(unsigned int size)
{
myarray = new Foo[size];
}
but that returns an error when compiling.
error: incompatible types in assignment of ‘Foo*’ to ‘Foo [0]’
any idea how to fix this?
struct Foo myarray[];should bestruct Foo *myarray;if you’re going to go with it in a dynamic approach. Otherwise, if you want it to be an unspecified static I think it has to have an initialization list.