title: C++: multidimensional array initialization in constructor
body: <p>I want to use a two dimensional array of constant size as a class member in C++. I have problems initializing it in the constructor though.</p>
  
  <p>Here are my non-working tries:</p>
  
  <p>1.)</p>
  
  <pre><code>class A {
   public:
    int a[2][2];
    A();
  };
  
  A::A() {
  a = {{1,2},{2,4}};
  }
  </code></pre>
  
  <p>yields: <code>error: assigning to an array from an initializer list</code></p>
  
  <p>2.)</p>
  
  <pre><code>class A {
   public:
    int a[2][2];
    A();
  };
  
  A::A() {
  int b[2][2] = {{1,2},{2,4}};
  a = b;
  }
  </code></pre>
  
  <p>yields: <code>invalid array assignment</code></p>
  
  <p>3.)</p>
  
  <pre><code>class A {
   public:
    int **a;
    A();
  };
  
  A::A() {
  int b[2][2] = {{1,2},{2,4}};
  a = b;
  }
  </code></pre>
  
  <p>yields: <code>cannot convert ‘int [2][2]’ to ‘int**’ in assignment</code></p>
  
  <p>I come from C background. I know that I could use <code>std::vector</code> and I am aware of the disadvantages this approach has but since this is an exercise for me I would like to know how to get it working with plain arrays. I should add that I want to work on this array later on. I want to change the stored values but <strong>not</strong> the size. Maybe that matters as well (I figured a <code>const</code> at the right place could help somehow?).</p>