We are trying to use a 2D vector because we want the 2D array to dynamically evolve.
We tried this: In the class declaration:
vector<vector<double> > table;
But then the table does not stand out. When we try to access members, we get segfault.
So, we tried this:
Class declaration:
vector<vector<double> >* table;
Constructor:
table = new vector<vector<double> >;
But now we got to it before (with [] []) not working.
We tried a dummy class with this:
class myClass { public: myClass(); ~myClass(); vector<vector<double> > t; }; myClass::myClass() { t = vector<vector<double> > (10, vector<double>(10)); }
But he will not be freed properly, and we got the main landfill. Also, when we tried to grow an array, we would successfully build each new row.
Example:
t[50] = vector<double>(5); t[50][10] = 10;
If we did not, we would get segfault
mdogg source share