This is what the compiler says: it cannot create a default constructor or assignment operator for your structure, since it has a const member ( const bool fooBool ). structure elements that are const or that are references cannot be initialized by default, so they must be explicitly initialized in a user-written constructor or assignment statement.
One solution is to write your own default constructor and assignment operator (and according to the rule of the three options , you should also write a copy constructor, the destructor isnβt strictly necessary, but this is good practice). An alternative, simpler solution is to simply make fooBool not const . Then the compiler will happily generate a default constructor and assignment operator for you.
Since you are already creating an array from const instances with static const fooStruct foo[] = ... , the extra const on fooBool pointless.
source share