Using a vector data structure - design and syntax questions
<p>I have some basic C++ design/syntax questions and would appreciate your reply. </p>

<ul>
<li>I have N number of regions </li>
<li>Each region needs to store information about an object "element" </li>
</ul>

<p>i.e. I want to achieve something like this: </p>

<p><code>region[i].elements</code> = list of all the elements for region i.  </p>

<p><strong>Question 1:</strong> 
Does the following syntax (see code below) / design look correct. Am I missing anything here?</p>

<p><strong>EDIT</strong></p>

<p><em>The instances of struct elem are created by some other class and its memory deallocation is handles by that class only I just want to access that object and its members using reg[i].elements list (vector)  ... so, how should I add these element objects to the vector "elements" in class Region?</em> </p>

<p>//Already have this stucture that I need to use</p>

<pre><code>struct elemt {
  int* vertex; 
  int foo1;
  double foo2;
};


class Region{
   public:
      // I am not sure what should be the syntax here! 
      // is it correct?
      std::vector &lt;elemt*&gt; elements;      
}

// Following is the constructor of "class A"
A::A(){
    // --header file defines: Region *reg;
    // Let numOfRegions be a class variable. ( changes based on "Mac"'s suggestion)
    numOfRegions = 100;
    //allocate memory:
    reg = new Region[numOfRegions];
}

A::~A(){
  delete [] reg;
  reg = NULL;
}

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);

}
</code></pre>

<p><strong>Question 2:</strong> 
Is the syntax in <code>doSomething()</code> correct? Later I want to run an iterator over all the elements in <code>reg[i]</code> and want to access, <code>e1-&gt;foo1, e1-&gt;foo2</code> and like that. </p>

<p><strong>Question 3:</strong>
In do something method, how do I ensure that e1 is not already in the "elements" </p>

<p><strong>UPDATE</strong></p>

<p>Corrected some syntax errors, and hopefully fixed memory leak noticed by user 'Mac. '</p>
