i got this code from microsoft on a 2d matrix. perhaps its not working because im using Dev-C++/gcc
Code:
#include <vector>
using namespace std;
template <class T>
class C2DVector
{
public:
C2DVector():m_dimRow(0), m_dimCol(0){;}
C2DVector(int nRow, int nCol) {
m_dimRow = nRow;
m_dimCol = nCol;
for (int i=0; i < nRow; i++){
vector<T> x(nCol);
int y = x.size();
m_2DVector.push_back(x);
}
}
void SetAt(int nRow, int nCol, const T& value) throw(std::out_of_range); {
if(nRow >= m_dimRow || nCol >= m_dimCol)
throw out_of_range("Array out of bound");
else
m_2DVector[nRow][nCol] = value;
}
T GetAt(int nRow, int nCol) { //ERROR ON THIS LINE
if(nRow >= m_dimRow || nCol >= m_dimCol)
throw out_of_range("Array out of bound");
else
return m_2DVector[nRow][nCol];
}
<snip>
error: 24 C:\Nabeel\segment_model\C2dvector.h
parse error before `)' token
if you want me to post the rest of the code i for the class, i will. i saved it in a file called C2DVector.h, maybe that has something to do with it?
-Nabeel