
C++ 11
C++ 从入门到放弃
dabusidede
Github:https://github.com/IceEmblem,
Word文档文章:https://github.com/IceEmblem/LearningDocuments
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
c++ Linux VSCode 环境搭建
GCC的安装# 安装gcc$ sudo apt-getinstall gcc安装插件在VSCode编写和调试程序是需要安装相关的插件才能进行的。在这里我们选择安装C/C++、C++ Intellisense、Code Runner和Include Autocomplete这四插件。Helloworld新建一个helloworld.cpp源文件配置智能感知Ctrl+Shift+P运行C/CPP: Edit configuration ...命令...原创 2020-07-24 11:46:31 · 373 阅读 · 0 评论 -
c++解读复杂的定义式
Thinking in C++ 里 作者介绍了一个简单的方法来解读复杂的定义式, 称为right-left guideline. 简单的说就是从中间的变量名开始, 按右-左-右-左…的顺序来读. 以这个题目为例:ch原创 2020-07-23 12:24:19 · 326 阅读 · 0 评论 -
19 c++ 特殊工具与技术
#include <iostream>#include <vector>#include <cstdlib>#include <functional>#include "./Programmer.h"using namespace std;void NewDeleteTest();void DynamicCastTest();void MemberPTest();int main(){ NewDeleteTest();原创 2020-07-23 12:23:28 · 246 阅读 · 0 评论 -
18 c++ 用于大型程序的工具
#include <iostream>#include <vector>#include <tuple>#include <bitset>#include <regex>#include <random>using namespace std;void exceptionTest();int main(){ exceptionTest(); cout << "enter key" <原创 2020-07-23 12:22:22 · 235 阅读 · 0 评论 -
17 c++ 标准库特殊设施
#include <iostream>#include <vector>#include <tuple>#include <bitset>#include <regex>#include <random>using namespace std;void TupleTest();void BitsetTest();void RegexTest();void Randomtest();void IOTest();原创 2020-07-23 12:19:08 · 243 阅读 · 0 评论 -
16 c++ 模板与泛型编程
#ifndef Color_H#define Color_H#include <string>#include <type_traits>#include <utility>class Color{private: std::string _value;public: Color(std::string value):_value(value){}; std::string getValue() const{ return _原创 2020-07-23 12:18:21 · 237 阅读 · 0 评论 -
15 c++ 面向对象设计
#ifndef Slump_H#define Slump_H// 水果class Slump{private:protected: int _price;public: Slump(int price):_price(price){}; Slump(Slump&) = default; // 虚函数,如果希望子类可以有自己特定的版本,应使用virtual标识 virtual double Price(){ return _p原创 2020-07-23 12:16:18 · 212 阅读 · 0 评论 -
14 c++ 重载运算符与类型转换
运算符重载#include <iostream>#include <string>#ifndef Pan_H#define Pan_Hclass Pan{ friend Pan operator+(Pan &left, Pan &right); friend std::ostream &operator<<(std::ostream &left, Pan &right); friend std原创 2020-07-23 12:14:17 · 271 阅读 · 0 评论 -
13 c++ 拷贝控制
拷贝,赋值,移动构造函数class Book{// 这里我们定义的swap函数,这样在标准库容器中swap时将使用我们的swap函数而不是标准库的friend void swap(Book &left, Book &right);public: // 默认构造函数 Book() = default; // 拷贝构造函数,如果我们没有定义拷贝构造函数,编译器会帮我们定义 // 编译器生成的拷贝,其成员采用拷贝的形式生成 Book(const Book &boo原创 2020-07-23 12:12:24 · 208 阅读 · 0 评论 -
12 c++ 动态内存
内存// 静态内存:保存 static数据 和 全局变量 等// 栈内存:保存局部变量// 堆内存(动态内存):程序运行时分配的对象// c++ 动态内存管理使用 new 分配,delete 删除// c++ 提供了两种智能指针(行为像指针的类),可以安全的管理动态分配的内存,即使出现异常智能指针也能安全的释放内存智能指针 // shared_ptr,允许其他shared_ptr指针贡献一个内存,当所有的shared_ptr被销毁,内存也会被销毁 // shared_ptr原创 2020-07-23 12:08:12 · 233 阅读 · 0 评论 -
11 c++ 关联容器
关联容器类型// 关联容器支持高效的关键子查找// 有序容器map<int, string> map1; // 键值对set<int> set1; // 键multimap<int, string> map2; // 键值对,允许键重复multiset<int> set2; // 键,允许键重复// 无序容器,使用哈希排序unordered_map<in原创 2020-07-23 12:04:23 · 359 阅读 · 0 评论 -
10 c++ 泛型算法
本示例使用的头文件#include <iostream>#include <vector>#include <algorithm>#include <numeric>#include <functional>#include <list>#include <iterator>基本函数vector<int> numList { 1, 2, 3, 4 };// 查找值,范围 numList.be原创 2020-07-22 12:53:49 · 239 阅读 · 0 评论 -
9 c++ 顺序容器
容器类型// 现代 c++ 应该使用标准库容器而不是内置数组,int a[]为内置数组vector<string> a; // 可变数组deque<string> b; // 双端队列,支持头尾插入list<string> c; // 双向链表,支持双向顺序访问,可以在认可位置插入,插入速度快forward_list<string> d; // 单向链表,支持单向顺序访问array<string, 10> e; // 固定大小stri原创 2020-07-22 12:46:33 · 237 阅读 · 0 评论 -
8 c++ 流
标准流cin,cout继承了标准流int a;// 如果这里输入字符,如输入 cc ,后续的cin将无法正常进行(注:如果这里输入的是 cc ,由于无法给 a,那么 cc 还在 cin 流中)if (cin >> a){ /* 如果流有效(成功输入) */ cout << a << endl;}cin >> a;cout << cin.eof() << endl; // 如果流达到文件结束位置,返回 true(c原创 2020-07-22 12:44:02 · 222 阅读 · 0 评论 -
7 c++ 类
基本类的定义类可以使用struct或class标识struct:默认成员访问权限为publicclass:默认成员访问权限为private类一般使用头文件和源文件分离分离的方式,如下示例类的一般定义SalesData.h文件#include <string>#include <vector>#ifndef SalesData_H#define SalesData_H// SalesData声明struct SalesData{ // 友元函数声明,不属原创 2020-07-22 12:41:08 · 195 阅读 · 0 评论 -
6 c++ 函数
函数应该在被调用的前面声明int GetSize(string str); // 函数声明int main(){ auto size = GetSize("ABC"); cout << "Press any key to end" << endl; cin.get(); return 0;}int GetSize(string str) // 函数定义,如果没有声明会声明并定义{ return str.length();}局部静态对象int Ge原创 2020-07-22 12:30:55 · 243 阅读 · 0 评论 -
5 c++ 语句
for语句vector<string> list = {"A","BC"};for(auto item : list){}Goto语句int a = 1;if(a == 1){ goto end;}a = 2;end:return 0;原创 2020-07-22 12:15:49 · 220 阅读 · 0 评论 -
4 c++ 表达式
sizeof运算符// sizeof返回 类型 或 变量的类型 或 表达式 所占空间大小int size = sizeof("Hello");cout << size << endl; // 输出6vector<string> list = { };cout << sizeof(list) << endl; // 输出24vector<string> list1 = { "AB", "CD", "EF" };cout原创 2020-07-22 12:14:32 · 243 阅读 · 0 评论 -
3 c++ 字符串、常量、数组
using声明#include <stdio.h>#include <iostream>using std::cin; // 可以直接使用cin,无需携程std::cinusing namespace std; // 使用std命名空间,可以省略stdint main(){ cout << "Enter Continue" << endl; cin.get(); return 0;}标准库类型str原创 2020-07-22 12:12:19 · 739 阅读 · 0 评论 -
2 变量和基本类型
算术类型bool, char, wchar_t, char16_t, char32_t, short, int, long, long long, float, double, long double类型前加 unsigned 为无符合类型指定字面值的类型L’a’ // 宽字符u8”hi” // utf-8字符串变量定义与声明// 声明:使得该名字为程序所知,要想使用别处定义的名字,只需引入该声明即可// 定义:负责创建与名字关联的实体extern int a; // 声明变量a原创 2020-07-22 12:05:52 · 239 阅读 · 0 评论 -
1 c++ 11 教程系列简介
本系列教程基于 c++11,全面介绍 c++ 11 的特性语法如何学习笔者的所有教程均以简洁,一目明了为主,没有太多废话(因为记录的文档太多,在使用是多会来回进行查找),教程大多数都是代码的方式展示出来,而如何使用和一些说明均匀注释的方式展示出来,所以,阅读本教程,不用错过任何注释涵盖内容本系列教程包含 c++ 11 系列教程,单元测试简绍,cmake 的使用,Window、Linux 环境搭建,和其他知识点介绍知识前提阅读本教程,你应该对 c语言 有一定的了解,或者你之前有了解过 c++c+原创 2020-07-22 12:00:31 · 333 阅读 · 0 评论