title: C++, Class: Out-of-line declaration of a member error?
body: <p>I am trying to create a dynamic array using a class. In my header file I have the following code:</p>
  
  <pre><code>#ifndef DYNAMICARRAY
  #define DYNAMICARRAY
  #include &lt;iostream&gt;
  
  class Array 
  {
  
  public:
  
      Array(); // Constructor - Initialises the data members
      ~Array(); // Destructor - That deletes the memory allocated to the array
      void addTings (float itemValue); // which adds new items to the end of the array
      float getTings (int index); // which returns the item at the index
      void size(); // which returns the number of items currently in the array
  
  private:
  
      int arraySize;
      float  *floatPointer = nullptr;
  };
  
  #endif // DYNAMICARRAY
  </code></pre>
  
  <p>And in my .cpp file I have the following code:</p>
  
  <pre><code>#include "DYNAMICARRAY.h"
  
  Array::Array()
  {
      floatPointer = new float[arraySize];
  }
  
  Array::~Array()
  {
      delete[] floatPointer;
  }
  
  void Array::addTings (float itemValue);  // Out-of-line declaration ERROR
  {
      std::cout &lt;&lt; "How many items do you want to add to the array";
      std::cin &gt;&gt; arraySize;
  }
  
  float Array::getTings (int index);    // Out-of-line declaration ERROR
  {
  
  }
  
  void Array::size()
  {
  
  }
  </code></pre>
  
  <p>I am getting a Out-of-line declaration of a member must be a definition compile error on both of the lines:</p>
  
  <pre><code>float Array::getTings (int index);
  </code></pre>
  
  <p>and</p>
  
  <pre><code>void Array::addTings (float itemValue);
  </code></pre>
  
  <p>Does anyone have any idea why? I thought I had linked the header file to the cpp file correctly but obviously not?</p>