I am trying to create a matrix class but am having a small problem. Everything works just fine except that I want to be able to do something like this:
This gives me a non-l value error and I'm not sure how to get around this. Here are my classes:Code:matrix myMatrix(3,3); myMatrix[0][0]=0;
Code:class array { public: array(int); int operator [] (int index) const {return vec[index];} private: vector<int> vec; }; array::array(int num) { for (int x=0; x<num; x++) vec.push_back(0); } class matrix { public: matrix(int, int); array operator [] (int index) const {return vec[index];} private: vector<array> vec; }; matrix::matrix(int xVal, int yVal) { array myArray(yVal); for (int x=0; x<xVal; x++) vec.push_back(myArray); }



LinkBack URL
About LinkBacks


