title: Make multiple class object members of another class in C++
body: <p>I am having a trouble of putting multiple class objects as member of another class. To be more specific: lets assume we have 2 classes, A and B and class A is nested. I want the main function to have an array with 3 objects of class B. The first object will have 2 objects of class A, the second object will have 5 objects of class A and the third object will have 7 objects of class A. How can i do that? Below is one of my thoughts:</p>
  
  <pre><code>Class A{
  
  private:
     int variable;
  
  public:
     A(){
         cout&lt;&lt; A created! &lt;&lt;endl;
     }
  
    ~A(){
         cout&lt;&lt; A destructed! &lt;&lt;endl;
     }
  
  };
  
  
  Class B{
  
  private:
     A array[6]; //It will always create 6 elements of class A...
  
  public:
     B(){
         cout&lt;&lt; B created! &lt;&lt;endl;
     }
  
    ~B(){
         cout&lt;&lt; B destructed! &lt;&lt;endl;
     }
  
  };
  
  int main(){
  
  B* array[3];
  
  for (i = 0 ; i &lt;= 2 ; i++)
  {
      array[i] = new B(); //Every B element in array have 6 elements of class A
  }
  
  }
  </code></pre>
  
  <p>Thanks in advance!</p>