随笔分类 -  C++

记录C++一些知识点,同算法相比更倾向于语言本身
摘要:error: error: Couldn't apply expression side effects : Couldn't dematerialize a result variable: couldn't read its memory reason: variable got optimiz 阅读全文
posted @ 2023-11-13 11:40 0x7F 阅读(40) 评论(0) 推荐(0) 编辑
摘要:C89/C90 (ANSI C or ISO C) was the first standardized version of the language, released in 1989 and 1990, respectively C99 (ISO/IEC 9899:1999) C11 (ISO 阅读全文
posted @ 2023-10-14 20:34 0x7F 阅读(16) 评论(0) 推荐(0) 编辑
摘要:首先,问题的前提是:不同数据类型的实际大小是依赖于编译器的具体实现的,那么假设在一个long为8B的平台,使用long作为例如memcpy的参数进行数据移动,并且指定的要移动的字节数超过了4B所能表示的最大值,那么如果将此代码移动到一个long为4B的平台,代码就会出现问题,因为此时的long已无法 阅读全文
posted @ 2023-10-14 20:34 0x7F 阅读(6) 评论(0) 推荐(0) 编辑
摘要:lambda structure [capture list] (parameter list) -> return type { function body } (parameter list) and return type are optional Value and Reference ca 阅读全文
posted @ 2023-09-27 13:56 0x7F 阅读(3) 评论(0) 推荐(0) 编辑
摘要:Operator[] The performance of [] in C and C++ is different. e.g., when you excute A[index] If A is a object, it will call the operator[] If A is a poi 阅读全文
posted @ 2023-09-22 21:47 0x7F 阅读(5) 评论(0) 推荐(0) 编辑
摘要:Asynchronization (Multithreading) The first thing we need to do is understanding the correlations between multithreading and parallel computing. Multi 阅读全文
posted @ 2023-09-10 22:06 0x7F 阅读(34) 评论(0) 推荐(0) 编辑
摘要:Using __cplusplus to check the version of C++ that is used by compiler. Reference [1] Replacing text macros [2] Standard Predefined Macros 阅读全文
posted @ 2023-09-03 20:57 0x7F 阅读(3) 评论(0) 推荐(0) 编辑
摘要:The collocation between const and original pointer is confused to many people. There are two usages of it. The first one is a variable pointer that po 阅读全文
posted @ 2023-09-03 16:14 0x7F 阅读(8) 评论(0) 推荐(0) 编辑
摘要:关于模版元编程和函数式编程,涉及到的是C++的5种编程范式,i.e. 1. 面向过程 2. 面向对象 3. 函数式 4. 范型 5. 模版元编程 模版元编程 元编程(metaprogramming)是指编写能够生成或操作其他程序的程序。 1. 写在尖括号内的包含两种内容:模版类型参数和非模版类型参数 阅读全文
posted @ 2023-09-03 12:42 0x7F 阅读(23) 评论(0) 推荐(0) 编辑
摘要:Related issues high correlation C++ 左/右值及其引用 论述 C++ 类成员函数全家桶 low correlation C++ 对象初始化方式对比 C++ 智能指针 std::move()本身的效果仅仅是类型上的转换(这里涉及到的就是左右值的问题), 但是和类的成员 阅读全文
posted @ 2023-08-29 00:20 0x7F 阅读(54) 评论(0) 推荐(0) 编辑
摘要:原始指针 要想了解智能指针,就需要首先了解原始指针的痛点,原始指针有几点问题 忘记释放内存 -> 产生内存泄漏 在尚有指针引用内存的情况下释放内存(使用已经释放掉的对象) -> 产生引用非法内存的指针 同一块内存释放2次 智能指针的产生本质上都是为了解决这些问题 关于使用new动态分配对象的初始化问 阅读全文
posted @ 2023-06-20 23:04 0x7F 阅读(49) 评论(0) 推荐(0) 编辑
摘要:> 说明: 本文探讨的是 C++11 以来的值类别 关于左值和右值,在不对其进行详细的划分时,简单的分类方法包括 > 1. 左值持久,右值短暂 > 2. 能取得地址得通常是左值,反之通常是右值(这一方法启示我们一个表达式的类型与其是左值还是右值无关,即相同类型的表达式既可以是左值也可以是右值) 右值 阅读全文
posted @ 2023-06-19 17:05 0x7F 阅读(32) 评论(0) 推荐(0) 编辑
摘要:为了叙述的方便,以下内容以赋值运算符为例 赋值运算符本质是一个名为`operator=`的函数,某些运算符必须定义为成员函数 赋值运算符定义示例代码 ``` class Foo { public: Foo& operator=(const Foo&); }; ``` 阅读全文
posted @ 2023-06-19 12:34 0x7F 阅读(10) 评论(0) 推荐(0) 编辑
摘要:普通类型 类类型 对于类类型,编译器只能自动执行一步隐式类型转换.例如从字符串字面值转换为string类型,但是无法继续将string隐式转换为其他类型 新式显示类型转换 格式 cast-name(expression); static_cast Any well-defined type conve 阅读全文
posted @ 2023-06-18 19:35 0x7F 阅读(6) 评论(0) 推荐(0) 编辑
摘要:RAII Resource Acquisition Is Initialization,资源获取即初始化 这是一种解决资源管理问题的方法,将资源的有效期与持有资源的对象的生命期严格绑定,由对象的构造函数完成资源的分配,由析构函数完成资源的释放 C++借助构造函数和析构函数,解决了传统的 malloc 阅读全文
posted @ 2023-06-18 18:48 0x7F 阅读(32) 评论(0) 推荐(0) 编辑
摘要:在了解创建对象的方式之前,首先了解一下**初始化**和**赋值**两个操作, 1. 初始化是创建变量时赋予其一个初始值,即初始化之前并不存在变量 2. 赋值是把对象的当前值擦除,用新值代替旧值,即赋值之前存在变量 让人困惑的是`=`既可以用于初始化,也可以用于赋值,不要认为初始化和赋值是相同的操作 阅读全文
posted @ 2023-06-18 17:18 0x7F 阅读(76) 评论(0) 推荐(1) 编辑
摘要:# cstdint > 自 C++11 开始被引入,旨在为 C++ 程序员提供一种可移植的方式来定义固定宽度的整数类型和相关常量,解决平台兼容性问题 以`uint64_t`为例,说明该头文件的作用 `uint64_t`是`unsigned long long`的类型别名, > `typedef un 阅读全文
posted @ 2023-06-05 19:03 0x7F 阅读(294) 评论(0) 推荐(0) 编辑
摘要:stdbasic_stringsubstr 函数定义及功能描述 注: 默认参数npos means "until the end of the string" 示例程序 #include<iostream> #include <string> using namespace std; int mai 阅读全文
posted @ 2021-10-17 23:17 0x7F 阅读(63) 评论(0) 推荐(0) 编辑
摘要:命名约定 Google 开源项目风格指南 数据类型 | Data Type | Size (in bytes) | Range | | | | | | short int | 2 | -32,768 to 32,767 | | unsigned short int | 2 | 0 to 65,535 阅读全文
posted @ 2021-10-04 16:38 0x7F 阅读(53) 评论(0) 推荐(0) 编辑
摘要:总结C语言和C++字符串和数字相互转换的方法 阅读全文
posted @ 2021-05-07 21:18 0x7F 阅读(706) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示