title: How do you create a private dynamic array in a c++ class?
body: <p>Hello I am having trouble with using dynamic arrays within a class. I am instructed that "the class VectorDouble will have a private member variable for a dynamic array of doubles." I am only as far as writing the header file for this program, but I have not gotten past that. This class needs to be able to double in size once it has reached capacity.
  Here is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  // VectorDouble class header file
  class VectorDouble
  {
      public:
      // constructor for an empty vector of type double
          VectorDouble();
      // constructor that take an int argument for an integer size of and array
          VectorDouble(int initial_size);
      // copy constructor
          VectorDouble(VectorDouble &amp;object);
      // destructor to return dynamic memory to the freestore
          ~VectorDouble();
      // overloaded operator = for VectorDouble class
          VectorDouble&amp; operator =(const VectorDouble &amp;source);
      // overloaded operator == for VectorDouble class
          friend bool&amp; operator ==(const VectorDouble &amp;this_vector,
                                   VectorDouble &amp;other_vector);
      // adds a new element at the end of the array
          void push_back();
      // returns allocated size of VectorDouble dynamic array
          int capacity();
      // returns used size of the VectorDouble object
          int size();
      // allocates a specified block of memory for specified number of double
      // type values
          void reserve(int new_reserve);
      // changes the size of the dynamic array
          void resize(int new_size);
      // returns the value at the specified index
          double value_at(int index);
      // changes the value at the specified index to double value d
          void change_value_at(double d, int index);
  
      private:
  
          int count;
          int max_count;
          int index_pointer;
          *index_pointer = new double[100]; 
  
  }; 
  </code></pre>
  
  <p>The errors I am getting are all on this line:*index_pointer = new double[100];</p>
  
  <ul>
  <li><p>`new' cannot appear in a constant-expression </p></li>
  <li><p>ISO C++ forbids declaration of `index_pointer' with no type </p></li>
  <li><p>ISO C++ forbids initialization of member `index_pointer' </p></li>
  <li><p>making `index_pointer' static </p></li>
  <li><p>invalid in-class initialization of static data member of non-integral
  type `int*'</p></li>
  </ul>