I am writing program which will multiply matrix using threads. I have problem with filling dynamic int array (cannot use vector).
cpp file:
Matrix::Matrix(int n, int m)
{
mac_ = new int[n * m];
}
Matrix::Matrix(std::istream & is)
{
int tmp;
int i = 0;
is >> m_; //rows
is >> n_; //columns
Matrix(n_, m_); // using 1st constructor
while (is.peek() != EOF) {
is >> tmp;
mac_[i] = tmp; // debug stop here
i++;
}
}
part of hpp file:
private:
int n_; // columns
int m_; // rows
int *mac_;
From debug I get:
this 0x0079f7b0 {n_=3 m_=2 mac_=0x00000000 {???} }
I know that i can write mac_ = new int(n_*m_);
in 2nd constructor but I want to know why 1st does not work.