title: Is having std::vector of a class as an attribute the same class a good design choice?
body: <p>My problem statement is as below. There is a concept of "domain" which consists of many "subdomains". Now, those subdomains are domains in their own right. Following is the basic method I can do the things. I can probably use an auto_ptr or something, but lets leave it for now.</p>
  
  <pre><code>class Domain
  {
  private:
      Domain* subdomains;
  }
  </code></pre>
  
  <p>However, I was able to compile and run the following program which I think does the same thing and gives me what I want. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;string&gt;
  
  class Domain
  {
  private:
      std::string name_;
  public:
      std::vector&lt;Domain&gt; subdomains;
      Domain(std::string name) : name_(name) {};
      std::string name() {return name_;}
      void addSubDomain(std::string subDomainName);
  };
  
  void Domain::addSubDomain(std::string subDomainName)
  {
      subdomain.push_back(Domain(subDomainName));
  }
  
  int main()
  {
      std::cout&lt;&lt;"Hello, World"&lt;&lt;std::endl;
      Domain domain("wow");
      domain.addSubDomain("wow-child");
      std::cout&lt;&lt;"Domain name is "&lt;&lt;domain.name()&lt;&lt;std::endl;
      std::cout&lt;&lt;"Subdomain name is "&lt;&lt;domain.subdomain[0].name()&lt;&lt;std::endl;
      return 0;
  }
  </code></pre>
  
  <p>The output which I get on running this is </p>
  
  <pre><code>$./main 
  Hello, World
  Domain name is wow
  Subdomain name is wow-child
  </code></pre>
  
  <p>My question is whether there are any pitfalls that I may have missed while implementing the following thing? Right now, there is nothing I can see. If there are no pitfalls, then this is the a really good solution to my problems. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>In case this is not a solution, then is there another solution that I can use which does not involve the management of raw pointers? </p>