孤独的猫

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

2021年10月11日

摘要: for循环的新用法 我们知道,在C++中遍历一个容器的方法一般是这样的: #include <iostream> #include <vector> int main(void) { std::vector<int> arr; //... for(auto it=arr.begin();it !=a 阅读全文
posted @ 2021-10-11 21:07 孤独的猫 阅读(59) 评论(0) 推荐(0) 编辑

摘要: std::function是一个类末班,容纳除了类成员指针之外的所有可调用对象。 示例如下: #include <iostream>#include <functional> void func(void){ std::cout << __FUNCTION__ << std::endl;} clas 阅读全文
posted @ 2021-10-11 20:51 孤独的猫 阅读(34) 评论(0) 推荐(0) 编辑

摘要: 1.auto关键字 使用auto可以自动推导出变量类型,如 auto x=5; //x是int类型 static auto y=0.0 //y是double类型 auto pi=new auto(1) //pi被推到为int* 2.auto的推导规则 再来看一组例子 int x=0; auto * 阅读全文
posted @ 2021-10-11 18:29 孤独的猫 阅读(52) 评论(0) 推荐(0) 编辑