This is related to my other post. One of the suggestions here was to use vector for class Region.. as illustrated in the following code. I have a few more beginner questions --
a) How to allocate this vector a size = numOfRegions? Or do I really need to allocate a size to a vector?
b) How do I insert objects of class Region to this vector<Region>
? All these Region objects need to be managed by class A
c) I am assuming I don't need to delete this vector in class A's distructor .. correct?
struct elemt {
int* vertex;
int foo1;
double foo2;
};
class Region{
public:
std::vector <elemt*> elements;
int info;
}
class A{
public:
std::vector<Region> reg;
const int numOfRegions = 100;
}
A::A(){
// how to create and append Region object to vector std::vector<Region> reg ??
// Do I need to allocate size for this region vector?
}
A::~A(){
//do nothing
// Do I need to delete vector<Region> reg here ??
}
A::doSomething(){
// here I want to append the elements to the vector
// Let i be region 10.
// Let e1 be an element of "struct elemt" that needs to be added
reg[i].elements.push_back(e1);
}