struct comp {
long a;
vector<int> b(9);
bool c;
};
Errors:
code.cpp:67:19: error: expected identifier before numeric constant
code.cpp:67:19: error: expected ‘,’ or ‘...’ before numeric constant
What is wrong with this? Why doesn’t g++ accept if I say that b will have 9 elements?
Because C++ doesn’t work like that.
Initializers go in the initializer list of a constructor, e.g.
(Note that a class thus defined is no longer an aggregate.)
Note: C++11 adds member initializers, but only using copy-initialization syntax:
Compiler support for this is still incomplete.