flexible array member

Mar 21, 2019 at 5:02pm
Hello I have a problem:
I have 4 files: AllOnesGA.cpp, Population.h, Individual.h, GeneticAlgorithm.h

In Individual.h I declare
private:
int chromosome[];
And an error message was thrown
error: flexible array member ‘Individual::chromosome’ not at end of ‘class Individual’

What I'm doing wrong?
Mar 21, 2019 at 5:08pm
> What I'm doing wrong?
1. Using a FAM when you should be using std::vector.

2. Not reading the error message.
"not at end of ‘class Individual’" is very specific.
You can only have one FAM, and it MUST be the last member of the class/struct.
Mar 21, 2019 at 5:21pm
What is a FAM?
Thanks
Mar 21, 2019 at 5:23pm
You wrote it yourself
FAM = Flexible Array Member.
Mar 21, 2019 at 5:28pm
who knows
ISO C++ forbids flexible array member
Topic archived. No new replies allowed.