上一页 1 2 3 4 5 6 7 8 9 ··· 15 下一页
摘要: 1. 引入nullptr的必要性: 典型的指针初始化是将其指向一个空的位置。比如: int* my_ptr = 0; int* my_ptr = NULL; 一般情况下,NULL是一个宏定义。 NULL可能被定义为字面常量0,或定义为无类型指针(void*)常量。 一下代码显示了使用NULL引起的意 阅读全文
posted @ 2019-09-04 11:40 c++11 阅读(1026) 评论(0) 推荐(0) 编辑
摘要: C++程序中有以下几种推出方式:terminate abort exit terminate: 实际上是c++语言中异常处理的一部分(包含在<exception>头文件中),一般而言,没有被捕获的异常就会被terminate函数调用。只要c++程序中出现了非程序员预期的行为,都有可能导致termin 阅读全文
posted @ 2019-09-03 11:53 c++11 阅读(1818) 评论(1) 推荐(0) 编辑
摘要: unique_ptr, shared_ptr 以及weak_ptr 1. example unique_ptr 与所指对象的内存绑定紧密,不能与其他unique_ptr类型的指针对象共享所值对象的内存。up2不能分享up1的所有权。这种所有权只能通过move()函数来转移。 shared_ptr允许 阅读全文
posted @ 2019-08-30 18:33 c++11 阅读(253) 评论(0) 推荐(0) 编辑
摘要: 1. 枚举:分本别类和数值的名字 程序中需要“数值的名字”时,有三种方式实现: (1)宏 #define Male 0 #define Female 1 (2)匿名的enum enum { Male, Female }; (3)静态常量 const static int Male = 0; cons 阅读全文
posted @ 2019-08-30 12:21 c++11 阅读(2013) 评论(0) 推荐(1) 编辑
摘要: 1. example code 变量 j 的类型由decltype(i)进行声明,表示 j 的类型跟 i 相同(或者准确的说,是与 i 这个表达式返回的类型相同)。而类型c则跟(a+b)这个表达式返回的类型相同。decltype总是以一个普通的表达式为参数,返回该表达式的类型。decltype的类型 阅读全文
posted @ 2019-08-28 10:53 c++11 阅读(330) 评论(0) 推荐(0) 编辑
摘要: 转:https://www.cnblogs.com/DswCnblog/p/5629165.html C++11的一大亮点就是引入了Lambda表达式。利用Lambda表达式,可以方便的定义和创建匿名函数。对于C++这门语言来说来说,“Lambda表达式”或“匿名函数”这些概念听起来好像很深奥,但很 阅读全文
posted @ 2019-08-22 18:31 c++11 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 1. 临时变量的拷贝 使用g++编译,不使用优化:g++ -std=c++11 -fno-elide-constructors test.cpp -o main 输出为: Construct: 1 Resource from GetTemp: 0x25d5c20 Move constructor: 阅读全文
posted @ 2019-08-20 16:52 c++11 阅读(384) 评论(0) 推荐(0) 编辑
摘要: UUIDs are used by distributed systems that have to uniquely identify components. For example, Microsoft uses UUIDs to identify interfaces in the COM w 阅读全文
posted @ 2019-08-13 17:46 c++11 阅读(1215) 评论(0) 推荐(0) 编辑
摘要: Archive An archive is a sequence of bytes that represented serialized C++ objects. Objects can be added to an archive to serialize them and then later 阅读全文
posted @ 2019-08-13 17:18 c++11 阅读(751) 评论(0) 推荐(0) 编辑
摘要: Boost.Integer defines specialized for integers. 1. types for integers with number of bits output: 1 8 1 4 1 8 types such as boost::int8_t and boost::u 阅读全文
posted @ 2019-08-11 21:38 c++11 阅读(214) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 15 下一页