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
CMatrixFun::CMatrixFun()
{
row=col=0;
mat=NULL;
}
// and this is the Random Generator constructor
CMatrixFun::CMatrixFun(int rows,int columns)
{
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)
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
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.