
please wait
|
|
vector<Tower> towers; Tower default_tower, tower; towers.push_back(tower); while (towers.back() != default_tower){ towers.back() = default_tower; } |
use a vector of pointers to point to that new instance of Tower, instead of storing the whole tower instance in the vector |
const char * name;
) to be the same name, but with a number on the end depending on what position in the vector it is, how can this be done, inside the constructor? If I was to make a default name, once it is constructed, I wouldn't be able to change it to add the number. So is there a way to do this inside the constructor? Or would it be easier just to make it char *name;
?vectors containing pointers (and owning the objects pointed to) violate RAII, so that is why you should use ptr_vector in this case. |