How could i initialize vector<class> in a class object?

Mar 6, 2013 at 10:25am
Hello everyone,

I want to make a class, named generation, having a vector<chromosome> type data member.
chromosome is also class name.
chromosome has a 'route' as data member, which type is class TArrayI defined in ROOT package.
the size of route is to be fixed according to parameters of generation class object.

class chromosome{
public: chromosome(){;}

....
protected:
TArrayI route;
};

class generation{
public: generation(int PopSize=300, int numCity = 36){
.........
}

vector<chromosome> Population;

};

I want each element, chromosome of Population, to have a numCity size of route.
thank you advance for your helps.
Last edited on Mar 6, 2013 at 10:36am
Mar 6, 2013 at 11:12am
You could do it in the constructor, or in the initialization list of the constructor.
Mar 6, 2013 at 11:54am
Thank you, i'll try it.
Topic archived. No new replies allowed.