I get the following error when I try to run this code in Visual Studio 2010:
Unhandled exception at 0x012c23d3 in matrix.exe: 0xC0000005: Access violation reading location 0xccccccd0.
Here's the code:
#include <vector> using namespace std; class matrix : public vector<vector<char>> { public: matrix(int x, int y) { this->resize(x); for (int i = 0; i < y; ++i) { this[i].resize(y); } } }; void main() { matrix mat(10, 10); } I'm trying to create a matrix class that expands on the vector<vector<char>> type by adding built-in matrix manipulation functions. However, I can't get this constructor to run properly.
Thanks for your help.
this[i]to a new vector.thisis a vector of vectors, andnew vectorcreates a pointer to a vector.