template <class Object>
class matrix
{
public:
matrix( int rows, int cols )
{
vOuter.resize(rows);
for(unsigned int i = 0; i < rows; i++)
vOuter.resize(cols);
NumOfRows = rows;
NumOfCols = cols;
}
matrix( const matrix &rhs)
{
vOuter(rhs.vOuter)
}
const vector<object> &operator[] (int row) const
{
return vOuter[row];
}
vector<Object> &operator[] (int row)
{
return vOuter[row];
}
unsigned int NumRows()
{
return NumOfRows;
}
unsigned int NumCols()
{
return NumOfCols;
}
private:
vector< vector<Object> > vOuter;
unsigned int NumOfRows;
unsigned int NumOfCols;
};
Whenever I call NumCols or NumRows such as below, it gives me the following error:
MatrixTest.cpp(15) : error C2039: 'NumRows' : is not a member of 'Matrix<int>'
MatrixTest.cpp(16) : error C2039: 'NumCols' : is not a member of 'Matrix<int>'
The code used to test them:
int main(int argc, char* argv[])
{
Matrix <int> Test(4,5);
Test[1][1] = 1;
Test[2][3] = 2;
int temp = 0;
cout << Test[1][1] << endl;
cout << Test[2][3] << endl;
cout << Test.NumRows() << endl;
cout << Test.NumCols() << endl;
return 0;
}
I posted this in another forum as well...but so far they haven't been able to help
class matrix
{
public:
matrix( int rows, int cols )
{
vOuter.resize(rows);
for(unsigned int i = 0; i < rows; i++)
vOuter.resize(cols);
NumOfRows = rows;
NumOfCols = cols;
}
matrix( const matrix &rhs)
{
vOuter(rhs.vOuter)
}
const vector<object> &operator[] (int row) const
{
return vOuter[row];
}
vector<Object> &operator[] (int row)
{
return vOuter[row];
}
unsigned int NumRows()
{
return NumOfRows;
}
unsigned int NumCols()
{
return NumOfCols;
}
private:
vector< vector<Object> > vOuter;
unsigned int NumOfRows;
unsigned int NumOfCols;
};
Whenever I call NumCols or NumRows such as below, it gives me the following error:
MatrixTest.cpp(15) : error C2039: 'NumRows' : is not a member of 'Matrix<int>'
MatrixTest.cpp(16) : error C2039: 'NumCols' : is not a member of 'Matrix<int>'
The code used to test them:
int main(int argc, char* argv[])
{
Matrix <int> Test(4,5);
Test[1][1] = 1;
Test[2][3] = 2;
int temp = 0;
cout << Test[1][1] << endl;
cout << Test[2][3] << endl;
cout << Test.NumRows() << endl;
cout << Test.NumCols() << endl;
return 0;
}
I posted this in another forum as well...but so far they haven't been able to help