help with random generator at matrix

Hello, I created a class that has the private ** matrix, coordinates of rows and columns.
I also created copy constructor and distructor, now my problem is that I need to produce a random generator of numbers between 0-30 in the constructor, a random generator to choose the numbers in the matrix sizes defined by the user chooses, and a bit messed up with this, tnx for helping.

//This is the default constructor

// and this is the Random Generator constructor
CMatrixFun::CMatrixFun(int rows,int columns)

srand (time(NULL));
for(int i=0;i<rows;i++)
for(int j=0;j<columns;j++)
can you elaborate the problem more?
yes, this is what i need to do, I can not do it properly, you have to remember my matrix is the Double Pointer

Constructor receiving two integers, CMatrixFun (int rows, int colums), which
The dimensions of the matrix) number of rows and number of columns (. Role of the constructor is to create a matrix by
Dimensions obtained and initialize the matrix field values ​​depending on these dimensions when
Values ​​in between 0 and 30 (the random generator will be accepted)
What I mean is, where/what is the problem you are facing. sorry for being not clear.
Random generator does not work, need help with the algorithm, I need to build the constructor and an executable (driver.cpp) I can print a matrix by size the user types and numbers will be random numbers by the constructor of the random generator
Did you allocate your matrix properly? Your default construct did it but the other one lacks an initialization of mat.
so how i initialization my mat at the second constructor?
its was close to what i did, but finally its work, tnx a lot, the problem was actually at the int main
this is the constructor if someone need

CMatrixFun::CMatrixFun(int rows,int columns)
mat = new double*[row];
for (int i = 0; i < row; ++i)
mat[i] = new double[col];
srand (time(NULL));
for(int i=0;i<row;i++)
for(int j=0;j<col;j++)
But your assertion check comes a little bit too late. Should be done before any access to mat. But its usually obsolete because new usually does throw std::bad_alloc in case.

And why do you add 0?
Topic archived. No new replies allowed.