c++11的auto关键字
c++11之前
c++11之前,auto关键字用来表示变量的存储期
类型推断
变量声明时可以用auto,编译器会自动推断数据类型
auto i = 10;
std::vector<int> v;
for (auto it = v.begin(); it != v.end(); it++) {
std::cout << *v << std::endl;
}
可见,auto使代码更简洁,增强了可读性。
Maybe nothing was found here.
c++11之前,auto关键字用来表示变量的存储期
变量声明时可以用auto,编译器会自动推断数据类型
auto i = 10;
std::vector<int> v;
for (auto it = v.begin(); it != v.end(); it++) {
std::cout << *v << std::endl;
}
可见,auto使代码更简洁,增强了可读性。