can someone show me a better way of accessing these elements besides the subscript operator. I cant work it out because of the nesting of vectors.
the vector should be a 0-31 by 0-31 int vector initialized to 0; i think its correct. i am just trying to decide if there is a better way to access the stuff. the subscript operator seems the most natural because i can picture the grid in my mind but everyone says its unsafe. i will need to access array elements both to the right of individual elements. also to the left and to the top and bottom.
this is what i have so far. note that this code is not 100% mine. it has been modified for my usage.
operator[] may allow you to access locations outside the vector. If you want to be sure that you never do that you can use the vector::at method. It's the same as operator[] but if the index is out of range, it throws an exception
i think im going to end up using the subscript operator. i looked at the example code for myvector.at(num) = myint but i cant figure out the syntext for a two dimensional vector of vector. i tried numerous combos and they always spit out an error.