title: C++ "Function" was not declared in this scope
body: <p>I was given an assignment in class to:</p>
  
  <blockquote>
    <p>Write a program that creates and manages arrays by the use of pointers. Your main program should interact with pointers/arrays only through various functions. These functions will then limit the use of array to their proper handling. For example these functions will eliminate the possibility of overstepping the boundaries of an array.</p>
  </blockquote>
  
  <p>So far I have written the program and fixed most of the errors, however no matter what I try I keep getting "function not declared in this scope" errors. The program includes the following files: <code>main.cpp</code> <code>MyArray.cpp</code> and <code>MyArray.h</code></p>
  
  
  
  <h3>main.cpp</h3>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include "MyArray.h"
  
  using namespace std;
  
  int main(int argc, char * argv[]) {
      int *Array1, *Array2;
      int Array1Size(10), Array2Size(10);
      int Array1Value(0), Array2Value(0);
  
      cout &lt;&lt; "Enter Size and Initial value for Array1: ";
  
      cin &gt;&gt; Array1Size &gt;&gt; Array1Value;
  
      cout &lt;&lt; "Enter Size and Initial value for Array2: ";
  
      cin &gt;&gt; Array2Size &gt;&gt; Array2Value;
  
      CreateArray(Array1, Array1Size);
      InitArray(Array1, Array1Size, Array1Value);
  
      CreateArray(Array2, Array2Size);
      InitArray(Array2, Array2Size, Array2Value);
  
      cout &lt;&lt; "Printing Array1:" &lt;&lt; endl;
      PrintArray(Array1, Array1Size);
      cout &lt;&lt; endl;
      cout &lt;&lt; "Printing Array2:" &lt;&lt; endl;
      PrintArray(Array2, Array2Size);
      cout &lt;&lt; endl;
  
      if(CopyArray(Array1, Array1Size, Array2, Array2Size)) {
          cout &lt;&lt; "Copy was successful" &lt;&lt; endl;
      } else {
          cout &lt;&lt; "Copy was not successful" &lt;&lt; endl;
      }
  
      cout &lt;&lt; "Printing Array1:" &lt;&lt; endl;
  
      PrintArray(Array1, Array1Size);
  
      cout &lt;&lt; endl;
  
      EnterArray(Array1, Array1Size);
  
      // MergeArray(Array1, Array1Size, Array2, Array2Size);
  
      cout &lt;&lt; "Printing Array1:" &lt;&lt; endl;
      PrintArray(Array1, Array1Size);
  
      cout &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>
  
  <h3>MyArray.h</h3>
  
  <pre class="lang-cpp prettyprint-override"><code>#ifndef _MyArray_h_included_
  #define _MyArray_h_included_
  
  class MyArray
  {
      public:
          void CreateArray(int *array, int size); 
          /*
          CreateArray(int *array, int size): Will accept a pointer to an array, and the size of the array and will allocate the appropriate amount of memory for the array
          */
          void InitArray(int *array, int size, int value);
          /*
          InitArray(Array1, Array1Size, Array1Value): Will initialize the contents of the arry Array1 to the value Array1Value
          */
          void PrintArray(int *array, int size);
          /*
          PrintArray(Array1, Array1Size): Will print the contest of the Array1
          */
          bool CopyArray(int *arrayOne, int sizeOne, int *arrayTwo, int sizeTwo);
          /*
          CopyArray(Array1, Arrary1Size, Array2, Array2Size): Will copy the contents of Array2 to Array1 iff the two arrays are of equal size. If the copying process is successfully completed, then a value of 1 is returned, otherwise a value of 0 is returned.
          */
          void EnterArray(int *array, int size);
          /*
          EnterArray(Array1, Array1Size): Will populate the Array1 from the stdin by prompting the user to enter all elements of the array.
          */
      };
  #endif
  </code></pre>
  
  <h3>MyArray.cpp</h3>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include "MyArray.h"
  
  using namespace std;
  
  void MyArray::CreateArray(int *array, int size) {
      array = new int[size];
  }
  
  /*
  CreateArray(int *array, int size): Will accept a pointer to an array, and the size of the array and will allocate the appropriate amount of memory for the array
  */
  void MyArray::InitArray(int *array, int size, int value) {
      for(int index(0); index &lt; size; index++) {
          array[index] = value;
      }
  }
  
  /*
  InitArray(Array1, Array1Size, Array1Value): Will initialize the contents of the arry Array1 to the value Array1Value
  */
  void MyArray::PrintArray(int *array, int size) {
      for(int index(0); index &lt; size; index++) {
          cout &lt;&lt; "Value of index: " &lt;&lt; index &lt;&lt; " is " &lt;&lt; array[index] &lt;&lt; endl;
      }
  }
  
  /*
  PrintArray(Array1, Array1Size): Will print the contest of the Array1
  */
  bool MyArray::CopyArray(int *arrayOne, int sizeOne, int *arrayTwo, int sizeTwo) {
      if(sizeOne != sizeTwo) {
          return false;
      } else {
          for(int index(0); index &lt; sizeTwo; index++) {
              arrayOne[index] = arrayTwo[index];
          }
  
          return true;
      }
  }
  
  /*
  CopyArray(Array1, Arrary1Size, Array2, Array2Size): Will copy the contents of Array2 to Array1 iff the two arrays are of equal size. If the copying process is successfully completed, then a value of 1 is returned, otherwise a value of 0 is returned.
  */
  void MyArray::EnterArray(int *array, int size){
      int index(0);
  
      while(index &lt; size) {
          int value(0);
          cout &lt;&lt; "Enter the value for index: " &lt;&lt; index + 1 &lt;&lt; endl;
          cin &gt;&gt; value;
          array[index] = value;
      }
  }
  /*
  EnterArray(Array1, Array1Size): Will populate the Array1 from the stdin by prompting the user to enter all elements of the array.
  */
  </code></pre>
  
  <p>The errors I get resemble this: <code>main.cpp:'LineNumber': error. 'Every Function in MyArray.cpp' was not declared in this scope</code> (I would copy paste the exact errors but I can't copy paste from the terminal I'm using to connect to the remote host were I compile my code)</p>
  
  <p><br/>I've been trying to fix this problem for hours and I can't figure it out, I've even looked at other Stack posts like <a href="https://stackoverflow.com/questions/6283168/foo-was-not-declared-in-this-scope-c">'foo' was not declared in this scope c++</a>
  <br/>Any help would be much appreciated, thank you.</p>
  
  <p>Also I did not write main.cpp, it was given with the assignment.</p>