title: Implement 2D matrix from classes C++
body: <p>I'm new to C++ and currently I'm trying to implement 2D matrix from classes, this is my current code, right now I'm unable to create an instance of the matrix object, please leave me feedback what I need to fix. </p>
  
  <p>*Updated: I have fixed some of the code, but the matrix doesn't print anything</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  using namespace std;
  
  class Matrix
  {
      public:
          Matrix(); //Default constructor
          Matrix(int *row, int *col); //Main constructor
          void setVal(int row, int col, int val); //Method to set the val of [i,j]th-entry
          void printMatrix(); //Method to display the matrix
          ~Matrix(); //Destructor
  
      private:
          int row, col;
          double **matrix; 
  
          //allocate the array
          void allocArray()
          {
              matrix = new double *[*row];
              for (int count = 0; count &lt; *row; count++)
                  *(matrix + count) = new double[*col];
          }
  };
  
  //Default constructor
  Matrix::Matrix() : Matrix(0,0) {}
  
  //Main construcor
  Matrix::Matrix(int *row, int *col)
  {   
      allocArray();
      for (int i=0; i &lt; *row; i++)
      {
          for (int j=0; j &lt; *col; j++)
          {
              *(*(matrix + i) + j) = 0;
          }
      }
  }
  
  //destructor
  Matrix::~Matrix()
  {
      for( int i = 0 ; i &lt; row ; i++ )
          delete [] *(matrix + i) ;
      delete [] matrix;
  }
  
  //SetVal function
  void Matrix::setVal(int row, int col, int val)
  {
      matrix[row][col] = val;
  }
  
  //printMatrix function
  void Matrix::printMatrix()
  {
      for(int i = 0; i &lt; row; i++)
      {
          for(int j = 0; j &lt; col; j++)
              cout &lt;&lt; *(*(matrix + i) + j) &lt;&lt; "\t";
          cout &lt;&lt; endl;
      }
  }
  
  
  int main()
  {
      int d1 = 2;
      int d2 = 2;
  
      //create 4x3 dynamic 2d array
      Matrix object(&amp;d1,&amp;d2);
  
      object.printMatrix();
  
      return 0;
  }
  </code></pre>