0

please check out the following two code segments and suggest which one is more efficient and worthy to use...

The segments are actually constructors used to allocate a memory block for a matrix..

segment - 1 :

```
class matrix
{
private :
int rows, columns;
int *element;
public :
// constructors
matrix();
matrix (int , int);
// member functions
};
matrix :: matrix (int r, int c)
{
rows = r;
cols = c;
element = new int [r * c];
}
```

segment - 2 :

```
class matrix
{
private :
int rows, columns;
int **element;
public :
// constructors
matrix();
matrix (int , int);
// member functions
};
matrix :: matrix (int r, int c)
{
rows = r;
cols = c;
element = new int* [rows];
int i = 0;
while (i < rows)
{
*(element+i) = new int [cols];
++i;
}
}
```

well....i think 1st one is more efficient... ;) ....and obviously more simple...

please give your views... :)