I have some basic design and syntax issues in C ++, and I will be grateful for your answer.
- I have N number of regions.
- Each region must store information about the element
i.e. I want to achieve something like this:
region[i].elements = list of all elements for region i.
Question 1: Does the following syntax look right (see code below) / design. Am I missing something here?
EDIT
The struct elem instances are created by some other class, and its freeing memory is processed by this class, only I just want to access this object and its members using reg [i]. list (vector) ... so how should I add these element elements to vector "elements" in the Region class?
// Already have this structure that I need to use
struct elemt { int* vertex; int foo1; double foo2; }; class Region{ public:
Question 2: Is the syntax in doSomething() correct? Later I want to run an iterator over all the elements in reg[i] and want to access, e1->foo1, e1->foo2 and the like.
Question 3: In some method, how can I guarantee that e1 is not yet in the "elements"
UPDATE
Some syntax errors have been fixed and, hopefully, a memory leak detected by a Mac user has been fixed.
source share