I am making a matrix template class it is declared as follows:
When I declare a variable of type CMatrix and use this constructor:Code:template <typename T> class CMatrix { private: vector<vector<T> > matrix; int numCols; int numRows; public: CMatrix(void) { numCols=1; numRows=1; matrix.resize(numRows); matrix[1].resize(numCols); } CMatrix(int nCols,int nRows);//to initialize a Matrix ~CMatrix(void); int GetNumCols(); int GetNumRows(); void SetNumCols(); void SetNumRows(); int InsertColumn(vector<T> col); int InsertRow(vector<T> row); int InsertColumnAt(vector<T> col, int index); int InsertRowAt(vector<T> row, int index); vector<T> RemoveColumnAt(int index); vector<T> RemoveRowAt(int index); T GetElementAt(int row, int col); int SetElementAt(T element, int row, int col); int AddMatrix(CMatrix<T> m); int SubtractMatrix(CMatrix<T> m); int MultiplyMatrix(CMatrix<T> m); int DivideMatrix(CMatrix<T> m); int AddScalar(int scalar); int SubtractScalar(int scalar); int MultiplyScalar(int scalar); int DivideScalar(int scalar); int RotateX(int angle); int RotateY(int angle); int RotateZ(int angle); int Transpose(); int LeastSquares(); int Inverse(); }; The function I have problems with is the constructor that takes 2 integer parameters to define the size of the matrix: template <typename T> CMatrix<T>::CMatrix(int nCols, int nRows) {//create a new matrix of size nRows x nCols numCols=nCols; numRows=nRows; matrix.resize(numRows); for(int i=0; i<numRows;i++){ matrix[i].resize(numCols); } }
I get the compiler error C2059: syntax error: 'constant'Code:CMatrix <int> test(5,10);
I am using Visual C .Net
I can't find any explanation for this specific C2059 error. Any help would be appreciated.
Thanks.
Sara



LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.