Thursday 30 May 2019

c++ - multi-dimensional vectors and pointers to vectors

I am trying to store pointers to vectors of pointers to vectors in a vector. (I hope that wasn't too mind boggling). Basically, I have a vector and I want to store multiple matrices in it, hence the 3 dimensions. There seems to be a problem with the way I am accessing elements. I don't particuarlily understand the error because the 3rd dimension is a pointer to a vector of ints. I don't think that should change the way you access the ints.



using namespace std;

vector< vector< vector* >* > matrixHolder;

int main() {

vector< vector* >* a;


a->push_back(new vector(10, 0));

matrixHolder.push_back(a);

matrixHolder[0][0][0] = 5; //Line 34


return 0;
}



main.cpp:34: error: invalid conversion from ‘int’ to ‘std::vector < int, std::allocator < int> >*’

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...