title: Instantiating private string array in C++
body: <p>Declared in arraystorage class, <code>private: string *names;</code></p>
  
  <pre><code>ArrayStorage&amp; ArrayStorage::operator=(const ArrayStorage&amp; rhs)
  {           
      // possible error
      names = new string[numOfElements];
  
      return *this;
  }
  
  //      copy constructor
  ArrayStorage::ArrayStorage(const ArrayStorage&amp; rhs):
                                   names(new string[numOfElements]),                                                      
  
                                   numOfElements(rhs.numOfElements)
  {
      //names = new string[this-&gt;getNumOfElements()];
  
      for (int i = 0; i &lt; this-&gt;getNumOfElements(); i++)
          names[i] = rhs.names[i];
  
  }
  
  ArrayStorage::~ArrayStorage(void)
  {
      delete [] names;
  }
  </code></pre>
  
  <p>================================ ArrayStorage.cpp==============================</p>
  
  <p>My first problem, if I declare names as private, the whole thing doesn't work. It works if I put it as public.</p>
  
  <p>Secondly, can you please advise, how do I make it work, if I want to declare <code>string *names</code> as private?</p>