When I create a 2-dimensional vector in c++ such as
vector < vector<int> > matrix(3, vector<int>(4));
would matrix[2][3] be accessible or would matrix[3][2] be accessible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You created the first dimension as 3 and the second as 4. That means that
matrix[3]is out of bounds. The other way around, though, would be fine- and would be fine regardless of which is which.