title: passing 2D array to another class C++
body: <p>I am trying to calculate the perimeter of a rectangle. first I will prompt the user 4 times for the X and Y cords and store it into a 2D array and pass this 2D array to another class which is method class to proceed with the calculation of the perimeter. But the problem is, I don't know how to pass the 2d array to method class. </p>
  
  <p>I am not asking how to calculate the perimeter, I only need to know how to pass the 2D array from main to method class and get the 2D array at method class.
  Please advise.</p>
  
  <p>main.cpp</p>
  
  <pre><code>Method method;
  int main() {
     int storeXandY[4][2];
         for(int i=1;i&lt;5;i++)
         {
             cout &lt;&lt; "Please enter x-ordinate" &lt;&lt; i&lt;&lt; endl;
             cin&gt;&gt;storeXandY[i][0];
             cout &lt;&lt; "Please enter y-ordinate" &lt;&lt; i &lt;&lt; endl;
             cin&gt;&gt;storeXandY[i][1];
         }
      //how to pass the 2D array to method class to do some calculations?
      // I was thinking something like passing the 2d array to a consturctor but don't know whether it can be done
         method.constructor(storeXandY);
   }
  </code></pre>
  
  <p>method.h</p>
  
  <pre><code>   //not sure of what to do
  
  public: 
      constructor() {
  
      }
  </code></pre>
  
  <p>method.cpp</p>
  
  <pre><code>    //how to get the cords from 2d array from main
  </code></pre>
  
  <p>Please advise. Thanks </p>