title: 2D complex array in C++
body: <p>I am new in C++ programing so I need a help about 2D arrays. Is it possible to create complex array from two real array with two for loops?I was trying to do that in my code but...I do not know how to do that.
  Thanks for help!
  This is my code::</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;complex&gt;
  #include &lt;cmath&gt;
  using namespace std;
  
  int const BrGr = 15, BrCv = BrGr + 1, BrSat = 24;
  //(BrCv=number of nodes,BrSat=number of hours)
  
  int main()
  {
      // Every array must be dynamic array.It is a task.Is this correct way?
  
      auto *Ipot = new double[BrCv - 1][BrSat];
      auto *cosfi = new double[BrCv - 1][BrSat];
      auto *S_pot = new complex&lt;double&gt;[BrCv - 1][BrSat];
      auto *I_inj = new complex&lt;double&gt;[BrCv - 1][BrSat];
      auto *V_cvo = new complex&lt;double&gt;[BrCv][BrSat];
  
      ifstream reader("Input.txt");
      if (reader.is_open())
      {
          for (int i = 0;i &lt; BrCv - 1;i++)
          {
              for (int j = 0;j &lt; BrSat;j++)
              {
                  reader &gt;&gt; Ipot[i][j];
              }
          }
          for (int i = 0;i &lt; BrCv - 1;i++)
          {
              for (int j = 0;j &lt; BrSat;j++)
              {
                  reader &gt;&gt; cosfi[i][j];
              }
          }
      }
      else cout &lt;&lt; "Error!" &lt;&lt; endl;
      reader.close();
  
      // Here i want to create 2D array of complex numbers -  Is this correct way?
      // Also in same proces i want to calculate a value of S_pot in every node for every hour
  
      for (int i = 0;i &lt; BrCv - 1;i++)
      {
          for (int j = 0;j &lt; BrSat;j++)
          {
              S_pot[i][j] = complex&lt;double&gt;(Ipot[i][j]*cosfi[i][j],Ipot[i][j]*sqr(1-pow(cosfi[i][j],2)));
          }
      }
      // Here i give a value for V_cvo in nodes for every single hour
  
      for (int i = 0;i &lt; BrCv;i++)
      {
          for (int j = 0;j &lt; BrSat;j++)
          {
              V_cvo[i][j] = 1;
          }
      }
  
      // Here i want to calculate a value of I_inj in every node for every hour
  
      for (int i = 0;i &lt; BrCv - 1;i++)
      {
          for (int j = 0;j &lt; BrSat;j++)
          {
              I_inj[i][j] = conj(S_pot[i][j] / V_cvo[i][j]);
          }
      }
  
      // Here i want to delete all arrays
  
      delete[] Ipot, cosfi, S_pot, I_inj, V_cvo;
      system("pause");
      return 0;
  </code></pre>