title: 2D array of object in C++
body: <p>I have a problem with assign object 2d <code>[5][5]</code> array to object. </p>
  
  <p>This is my array definition</p>
  
  <pre><code>class PrintRectangle : public QWidget
  {
  
  public:
      bool clicked[5][5] = {};
      teacher *tech;
      perceptron *p;
  
  };
  </code></pre>
  
  <p>And fragment <code>perceptron</code> class</p>
  
  <pre><code>class perceptron
  {
  public:
      perceptron&amp; operator=(const perceptron&amp;);
  };
  </code></pre>
  
  <p>When I try to assign object to my <code>perceptron *p</code> </p>
  
  <pre><code>PrintRectangle::PrintRectangle(QWidget *parent) : QWidget(parent)
  {
      tech = new teacher(clicked);
  
      *p = new perceptron[5][5];
  
      for(int i=0; i&lt;5; i++)
      {
          for(int j=0; j&lt;5; j++)
          {
              p[i][j] = new perceptron();
              p[i][j].randweight();
          }
      }
  
      double learnConst = 0.1;
      tech-&gt;learnPerceptrons(p);
  }
  </code></pre>
  
  <p>I get an error</p>
  
  <pre><code>    E:\Sieci Neuronowe\Perceptron\printrectangle.cpp:10: error: no match for 'operator=' (operand types are 'perceptron' and 'perceptron (*)[5]')
           *p = new perceptron[5][5];
              ^
  
  E:\Sieci Neuronowe\Perceptron\printrectangle.cpp:16: error: no match for 'operator[]' (operand types are 'perceptron' and 'int')
               p[i][j] = new perceptron();
                   ^
  </code></pre>
  
  <p>I have only </p>
  
  <pre><code>perceptron&amp; perceptron::operator=(const perceptron&amp;){
  
      return * this;
  }
  </code></pre>
  
  <p>In my perceptron class. How can I correct this? I don't cleary understend pointers.</p>