2
vector< vector<int> > vI2Matrix(3, vector<int>(2,0));

I know it declares size of two dimensional array and initializes it. But waht does (2,0 ) means? is there any necessary to put it here? thanks

When I delete (2,0) or change it to other value. The compilation is right but I got runtime segmentation fault after that.

1
  • If you are getting segmentation fault means, definitely you are not accessing the element that belong to the vector. (i.e., vI2Matrix is a 3*2 matrix in this case ) Commented Mar 18, 2011 at 1:31

1 Answer 1

4

The vector<int>(2,0) initializes the vector with two elements with the value of 0.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.