This code throws a warnings when I compile it under windows. Any solutions?
#include<vector>
int main(){
std::vector<int> v;
//...
for (int i = 0; i < v.size(); ++i) { //warning on this line
//...
}
}
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.
Replace all the definitions of
int iwithsize_t i.std::vector<T>::size()returns the typesize_twhich is unsigned (since it doesn’t make sense for containers to contain a negative number of elements).