title: Definition not found for print()
body: <p>New to C++ and trying to better understand why my code is giving me some red squiggly. </p>
  
  <p>My code is </p>
  
  <pre><code>string print() {
  string answer = "";
  for(int i = 0; i &lt; numOfElements - 1; i++) {
      answer += (arr[i] + '0');
      answer += ',';
  </code></pre>
  
  <p>I am getting the error under print and also my first bracket { </p>
  
  <p>Not sure if I need to post more, but I don't really get the problem I am having. </p>
  
  <pre><code>expected a ';' 
  Function definition for 'print' not found.
  </code></pre>
  
  <p>Error when I highlight the code.</p>
  
  <p>Even when I do put a semi colon I get the same error.</p>
  
  <p>Thanks for the help, and appreciate it.</p>
  
  <pre><code>class DynamicArray {
  private:
      int *arr;
      int arraySize;
      int numOfElements;
  
  DynamicArray(int arraySize) {
      if (arraySize &lt;= 1)
          arr = new int[1];
      else
          arr = new int[arraySize];
  }
  
  DynamicArray(const DynamicArray &amp;a) {
      arr = new int[a.arraySize];
      for (int i = 0; i &lt;= a.numOfElements; i++) {
          arr[i] = a.arr[i];
      }
      numOfElements = a.numOfElements;
      arraySize = a.arraySize;
  }
  public:
      int getArraySize() {
          return arraySize;
      }
      int getNumOfElements() {
          return numOfElements;
      }
  
  };
  string print() {
      string answer = "";
      for (int i = 0; i &lt; numOfElements - 1; i++) {
          answer += (arr[i] + '0');
          answer += ',';
      }
      answer += (arr[numOfElements - 1] + '0');
      return answer;
      }
  </code></pre>