jeudi 3 mars 2016

initialize a vector with differentes instances of a class (has random parameters)

I'm tying to get a vector of Ind class with 30 different instances (some parameters inside Ind class are genetated randomly)

Ind prueba(n, e0);
cout << prueba.getVariables() << endl; //get variables method return a vector
Ind prueba2(n, e0);
cout << prueba2.getVariables();

If I created two instances like that, both of them are different in the Variables attribute ( a vector with random components)

I'm trying to make a vector full with different instances of that class with the constructor

vector<Ind> padres(30, Ind(n, e0)); //n and e0 are ints and are irrelevant for the problem

but it looks like the vector "padres" contains just one instance 30 times.

thanks to all of you in advance

Aucun commentaire:

Enregistrer un commentaire