C++

functor仿函数

重载函数调用(),可当作函数使用。
跟函数指针相比,能保存状态(即struct的private变量)
https://stackoverflow.com/questions/356950/what-are-c-functors-and-their-uses
`
template
struct plus {
T operator(const T &a, const T &b) const {return a + b};

//greater : functor greater
priority_queue<int, vector greater> pq;
`

explicit 修饰单参数构造函数

避免隐式转换

`
class A {
public:
A(int _a) : a(_a){}
private:
int a;
}

A a(1)
A b;
b = 1 // non-explicit pass 隐式调用了构造函数
b = 1 // with explicit compile error
`

static

const 函数

对象指针指向null,并调用方法

字节对齐

inline 一定展开吗

静态变量初始化 头文件中static变量坏处

左值引用 右值引用 移动语义 移动构造函数 移动赋值函数

必须在构造函数初始化式里进行初始化的数据成员有哪些

STL里的内存池实现

C++四种类型转换:static_cast, dynamic_cast, const_cast, reinterpret_cast

STL 智能指针

析构函数能抛出异常吗

https://www.zhihu.com/question/34574154

posted @ 2018-09-10 17:46  hxidkd  阅读(175)  评论(0编辑  收藏  举报