#include <vector>
#include <iostream>
int main()
{
std::vector< int > v = { 1, 2, 3 };
for ( auto it : v )
{
std::cout<<it<<std::endl;
}
}
To what is auto expanding? Is it expanding to int& or int?
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.
It expands to int. If you want a reference, you can use
According to the C++11 standard,
autocounts as a simple-type-specifier [7.1.6.2], thus the same rules apply to it as to other simple-type-specifiers. This means that declaring references withautois no different from anything else.