title: How to initialize an array in a class constructor?
body: <p>Working in <a href="http://en.wikipedia.org/wiki/Xcode" rel="nofollow noreferrer">Xcode</a> on <a href="http://en.wikipedia.org/wiki/Mac_OS_X_v10.5" rel="nofollow noreferrer">Mac OS X Leopard</a> in C++:</p>
  
  <p>I have the following code:</p>
  
  <pre><code>class Foo{
  
  private:
      string bars[];
  
  public:
      Foo(string initial_bars[]){
          bars = initial_bars;
      }
  }
  </code></pre>
  
  <p>It does not compile and throws the following error:</p>
  
  <pre><code>error: incompatible types in assignment of 'std::string*' to 'std::string [0u]'
  </code></pre>
  
  <p>I notice that removing the line <code>bars = initial_bars;</code> solves the problem.
  It seems like I am not doing the assignment correctly. How could I go about fixing this problem?</p>
  
  <p>EDIT:</p>
  
  <p>The variable bars is an array of strings. In the main function I initialize it like this:</p>
  
  <pre><code>string bars[] = {"bar1", "bar2", "bar3"};
  </code></pre>
  
  <p>But it can contain an arbitrary number of members.</p>