Friday, 21 April 2017

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

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...