
C++
文章平均质量分 82
AthrunJ
Life is short, carpe diem!
展开
-
C++学习笔记-随机数
随机函数Rand SRand原理计算机常用线性同余法产生随机数,LCG( Linear Congruential Generator)用递推的方法求随机序列 X(n+1)=(a∗x(n)+c)%MX(n+1) = ( a * x(n) + c ) \% M其中:0<=a<M,0<=c<M,0<=x(0)<M.0<=a < M, 0<=c< M, 0<= x(0)< M. 为了计算迅速,M一般取2原创 2016-10-14 16:13:12 · 282 阅读 · 0 评论 -
Inside the C++ Object Model 读书笔记(六)
Runtime SemanticsAll globally visible objects in C++ are placed within the program data segment.In C, a global object can be initialized only by a constant expression, that is, one that can be evalu...原创 2019-07-09 09:44:16 · 351 阅读 · 0 评论 -
Inside the C++ Object Model 读书笔记(五)
文章目录Chapter 5. Semantics of Construction, Destruction, and Copy5.1 Object Construction without Inheritance5.2 Object Construction under Inheritancevirtual inheritanceThe Semantics of the vptr Initiali...原创 2019-06-20 13:33:50 · 258 阅读 · 0 评论 -
Inside the C++ Object Model 读书笔记(四)
文章目录Chapter 4 The Semantics of Function4.1 Varieties of Member InvocationName Mangling4.2 Virtual Member FunctionsMultiple InheritanceVirtual Functions under Virtual Inheritance4.3 Function Efficiency...原创 2019-06-20 13:31:43 · 175 阅读 · 0 评论 -
Inside the C++ Object Model 读书笔记(三)
文章目录Chapter 3. The Semantics of Data3.1 The Binding of a Data Member3.2 Data Member Layout3.3 Access of a Data Member3.4 Inheritance and the Data Member3.6 Pointer to Data MembersChapter 3. The Seman...原创 2019-06-20 13:29:07 · 276 阅读 · 0 评论 -
Inside the C++ Object Model 读书笔记(二)
文章目录The Semantics of Constructors2.1 Default Constructor Construction1. Member Class Object with Default Constructor (user defined constructor)2. Base Class with Default Constructor3. Class with a Vir...原创 2019-06-20 13:26:49 · 212 阅读 · 0 评论 -
Inside the C++ Object Model 读书笔记(一)
Chapter 1Chapter 1 Object Lessons1.1 The C++ Object Model1.2 A Keyword Distinction1.3 An Object Distinction1.4 Memory LayoutChapter 1 Object LessonsIn C, there is no language-supported relationship ...原创 2019-06-20 11:05:00 · 192 阅读 · 0 评论 -
深入理解C++11 读书笔记(八) 融入实际应用
数据对齐查询成员在类中的偏移量//Defined in header &lt;cstddef&gt;#define offsetof(type, member) /*implementation-defined*/C++11标准定义alignof函数查看数据的对齐方式,修饰符alignas重新定义对齐方式。C++11之前,一些编译器扩展描述对齐方式,比如GNU的 __att...原创 2018-08-02 12:09:27 · 189 阅读 · 0 评论 -
深入理解C++11 读书笔记(七) 改变思考方式
nullptr传统的C头文件stddef.h定义NULL#undef NULL#if defined(__cplusplus)#define NULL 0#else#define NULL ((void *)0)#endif由于NULL的二义性,在f(int),f(char *)里调用f(NULL)会调用int版本,不符合预期。为了避免类似错误,有的编译器做了自己的改...原创 2018-08-01 20:11:29 · 199 阅读 · 0 评论 -
深入理解C++11 读书笔记(六) 提高性能及操作硬件能力
常量表达式constexpr关键字,修饰函数,数据,构造函数等,是的编译器在编译器进行计算,编译时期常量。constexpr修饰函数时,要求(1.)原创 2018-07-31 11:15:56 · 283 阅读 · 0 评论 -
深入理解C++11 读书笔记(四) 易于编码的特性
c++11 对’>’的改进c++98中如果在模板定义中Y<X<int>>这样写会编译失败,>>之间需要有空格,在C++11中已经改进,不再需要空格。auto类型要求编译器 根据值对变量进行自动推导。因为是根据值来进行推导,因此必须是立即初始化变量,auto i;这种就非法。auto不是类型声明,而是占位符,在编译期间进行推导替换成实际...原创 2018-07-13 21:38:19 · 205 阅读 · 0 评论 -
深入理解C++11 读书笔记(三) 通用与专用
继承构造函数如果派生类并不需要改变构造函数,那么可以用新的using Base::Base直接继承基类的构造函数,基类构造函数很多的时候,这样做非常方便。如果派生类还有自己的成员需要初始化,可以利用类成员初始化表达。class A{ A(int a):a(a){} int a;};class B:A{ using A::A}使用继承构造函数,编译...原创 2018-07-13 16:07:06 · 297 阅读 · 0 评论 -
深入理解C++11 读书笔记(五) 提高类型安全
强类型枚举C与C++98/03 枚举是内置类型,全局可见,并不是使用“名字::成员名”的方式访问,无法隔离,enum成员容易互相污染。且与整型一一对应,enum之间没有类型区别,类型不安全。强类型枚举在enum 后面加上class。enum class EType{},无法隐式转换为整型,需要的时候可以显示转换。但强类型枚举之间可以使用比较运算符,而且类型安全。作用域不会输出到父作用域。可...原创 2018-07-17 23:56:19 · 175 阅读 · 0 评论 -
深入理解C++11 读书笔记(二) 稳定性和兼容性
兼容C99C99标准在C++98之后,因此C++11为了兼容C99,增加预定义宏 预定义标志 __func__函数体内直接使用 __func__ 表示函数名的字符串,__func__等效于const static char * __func__ = "***"不能作为函数参数的默认值,此时还未定义。不过可以在构造函数的初始化列表里使用。_Pragma操作符_Pra...原创 2018-07-11 17:57:37 · 317 阅读 · 0 评论 -
深入理解C++11 读书笔记(一)新标准
标准诞生c++98是c++11上一个版本的标准,c++03是对c++98的勘误,并没有本质上的更新,因此c++98/03经常被合称。c++0x是原本计划的新标准代号,乐观于10年之前完成,结果11年完成,于是标准名为c++11c++11 带来约140多个新特性,600多个 98/03缺陷修正。设计目标:更好的适用于系统开发和库开发、语法一致和简单化、兼容98/03和C引入...原创 2018-07-11 11:18:50 · 209 阅读 · 0 评论 -
Inside the C++ Object Model 读书笔记(七)
TemplatesOriginally viewed as a support for container classes such as Lists and Arrays, templates are now thegeneric programming (the Standard Template Library).attribute mix-in where, for example...原创 2019-07-23 13:33:54 · 226 阅读 · 0 评论