title: Create a dynamic array within a class (C++)
body: <p>I'd like to implement a class with an array. If the size of the array is being breached, I would call a resize() function. However I can't seem to code a dynamic array as a data member. Can someone guide me on how to work around this?</p>
  
  <p>This is what I got so far:</p>
  
  <pre><code>class ArrayList
  {
          public:
          ArrayList()
          {
                  array[ARR_SIZE] = {0};
                  space = 0;
                  size = ARR_SIZE;
          }
          void insert(int place, int value)
          {
                  if (place &gt;= size)
                          cout &lt;&lt; "Sorry, that index is not accessible" &lt;&lt; endl;
                  else
                  {
                          array[place] = value;
                          space++;
  
                  if(space == size)
                          allocate();
                  }
          }
          void remove(int place)
          {
                  if(place &gt;= size)
                          cout &lt;&lt; "Sorry, that index is not accessible" &lt;&lt; endl;
                  else
                  {
                          array[place] = NULL;
                          space--;
                  }
  
          }
          void allocate()
          {
                  int* array = new int[size*2];
                  size = size*2;
          }
          int usedSize()
          {
                  return space;
          }
          int totalSize()
          {
                  return size;
          }
          private:
          int array[ARR_SIZE];
          int space;
          int size;
  };
  </code></pre>