随笔分类 - B---C++易错知识点
摘要:1. 构造函数 2. 析构函数 3. 拷贝构造函数 4. 赋值函数 5. 字符串连接 6. 判断相等和返回长度 7. string声明方式 8. c++字符串和c字符串的转换 9. string和int类型的转换
阅读全文
摘要:1. 单例模式 类的所有静态变量都必须在类的外部初始化,格式是:类型名 类名::变量名=初始值;而不管它是私有的还是公有的。
阅读全文
摘要:1. 不要自己手动管理资源 2. 一个裸指针不要用两个shared_ptr管理,unique_ptr 3. 使用shared_ptr作为函数的接口,如果有可能用 const shared_ptr&的形式 4. shared_ptr weak_ptr和裸指针相比,会大很多,并且效率上会有影响,尤其在多
阅读全文
摘要:1. 几种智能指针 1. auto_ptr: c++11中推荐不使用他(放弃) 2. shared_ptr: 拥有共享对象所有权语义的智能指针 3. unique_ptr: 拥有独有对象所有权语义的智能指针 4. weaked_ptr: 到 std::shared_ptr 所管理对象的弱引用 1.1
阅读全文
摘要:参考学习:https://www.cnblogs.com/xuelisheng/p/9339924.html 1. 回调函数定义 回调函数就是一个通过函数指针调用的函数。 如果你把 函数的指针(地址)作为参数传递给另一个函数,当这个指针被用来调用其所指向的函数时,我们就说这是回调函数。 回调函数不是
阅读全文
摘要:参考:https://www.cnblogs.com/cly-blog/p/5980546.html
阅读全文
摘要:1. 在构造函数和析构函数中调用的虚函数并不具备虚函数的特性 因为基类的构造函数先构造, 析构函数后析构
阅读全文
摘要:1. 非静态成员 2. 静态成员变量 静态成员变量不占对象的内存空间 3. 成员函数 成员函数不占内存空间 4. 析构函数 5. 类中有虚析构函数 6. 继承空类和多重继承空类存储空间的计算 7. this指针
阅读全文
摘要:#include using namespace std; void testEmptyClass(); struct Empty { }; struct DummyEmpty { char a; }; template struct EmptyHelper : T { int group[256]; }; struct EmptyHelper2 { i...
阅读全文
摘要:#include #include #include class Empty{}; Empty e; Empty b = e; Empty d; Empty b = d; Empty f(b); //c98--同上 class Empty2 { public: //默认构造 Empty2() {} //拷贝构造 ...
阅读全文