Cherno的cpp教程笔记

Cherno的cpp教程笔记

this notebook is based on Cherno‘s Video Class in YouTube;if there is sth get confused,I can recheck the video which talk about it, or just google it.

  • this is not totally for newbie, so some basic information we should search it
  • And this is a important websize to tell us basic info about C++.

C++的常见数据类型和操作

C++的常见数据类型和操作

主要介绍一些常用数据类型的一些method,区别还有一些特殊的定义;

priority_queue 默认是大顶堆,great的话是小顶堆,less的话是大顶堆,自定义的话不知道是不是一致的

set默认top是小顶,这个大小我就不知道了,自定义的话,好像和我想得是一致的

所有的动态容器都是存放在heap上的,像是什么Vector,String,unordered_map之类的

指定精度的输出和计算

在腾讯的笔试中出现的需要指定精度和指定的计算精度的分析,在使用常数的时候一定要使用.0去修正一个方法。

Vector 动态数组

Vector中的一些常用的函数,方法,以及一些属性介绍和辨析

emplace_back & push_back(在末尾添加元素)

empalce_back直接在数组的末尾进行构造,而push_back借助于构造的临时变量再将其加入数组末尾,所以在一些操作中empalce_back对于空间时间的效率是会更高的,但是如果我们有重复构筑的数据的话,可能就需要使用push_back

要注意实际上vector中并没有append的方法。