My question is similar to this one, I think, but for C++, not C# (though the same answer may apply to both).
My question is also similar to this one (of which it has been marked a duplicate). The difference, however, is that that question asks about the constructor prototype, whereas mine asks about the constructor definition block.
Consider the following constructor definition block:
template <class T>
SimpleMatrix<T>::SimpleMatrix(int rows, int cols, const T& initVal)
: m_data(rows * cols, initVal)
, m_rows(rows)
, m_cols(cols)
{}
I'm a C++ newbie, and the CallOne() : call_two(), call_three(), call_four() {}
syntax is confusing me.
Is it equivalent to the following code block?
template <class T>
SimpleMatrix<T>::SimpleMatrix(int rows, int cols, const T& initVal)
{
vector <T> m_data(rows * cols, initVal);
m_rows = rows;
m_cols = cols;
}
Note that inside the SimpleMatrix
class definition, m_data
, m_rows
, and m_cols
are declared in the private
block as follows:
private:
int m_rows;
int m_cols;
vector<T> m_data;