title: Runtime pointer-exception while copying one array to another inside a function
body: <p>The main goal is to copy an array in the constructor from the <code>main()</code> function. Using <code>cin &gt;&gt;</code> would be really easily, but I have to give the constructor an already defined array. I don't get any errors when compiling the program. Only during runtime it fails with this exception:</p>
  
  <blockquote>
    <p>Unhandled exception thrown: read access violation. this->A was
    0x1110112.</p>
  </blockquote>
  
  <p>I've already tried to define these arrays in the class, even though I know this is not a good practice. But I can't do that as it will cause errors with pointers in another functions defined in this class. Here's what I got so far:</p>
  
  <pre><code>#include "pch.h"
  #include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #define size 5
  using namespace std;
  class Matr
  {
  private:
      //const int size = 5;
      double **A;
      double *B;
  public:
      Matr(double (*a)[size], double b[]) {
          for (int i = 0; i &lt; size; i++) {
              for (int j = 0; j &lt; size; j++) {
                  A[i][j] = a[i][j]; //here exception falls
              }
              B[i] = b[i];
          }
      }
  };
  int main()
  { 
      double A[5][5] = {              {-6,18,15,8,6},
                      {2,11,-18,17,23},
                      {-13,-2,8,-10,-5},
                      {1,13,11,-10,-5},
                      {10,21,8,-1,11} };
      double B[5] = { 0,-8,1,-2,-6 };
      Matr matr(A,B); //define the arrays
  }
  </code></pre>
  
  <p>I would like to define this to arrays in the class for using them in the other functions. Is this even possible at all? :D</p>