摘要: 析构函数 当类的对象撤销时,析构函数被隐式调用。析构函数不是释放内存,而是释放内存前进行扫尾工作。 对象何时撤销?1,静态分配的,生存期过后撤销。2,动态分配的,delete时撤销。 析构函数的命名 ~类型( ),析构函数没有形参和返回值。 一个类只能有一个析构函数,如果程序员不显示的提供析构函数, 阅读全文
posted @ 2018-02-24 10:46 AFreeMan 阅读(256) 评论(0) 推荐(0) 编辑
摘要: 拷贝构造函数的用途 拷贝构造函数,它由编译器调用来完成一些基于同一类的其他对象的构建及初始化。其唯一的形参必须是引用,但并不限制为const,一般普遍的会加上const限制。 拷贝构造函数发生的时机 1,用一个对象初始化另一个对象 Cat c1(); Cat c2(c1);2,函数按值传递 (实参 阅读全文
posted @ 2018-02-23 19:24 AFreeMan 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 时间复杂度:O(log2N) 证明: 阅读全文
posted @ 2018-02-22 16:29 AFreeMan 阅读(120) 评论(0) 推荐(0) 编辑
摘要: //C语言 int linearSearch(int *arr,int len,int key) { if(arr == NULL || len size_t linearSearch(const array &arr, const T key) { int i = 0; while (i < arr.size() && arr[i] != key) ... 阅读全文
posted @ 2018-02-22 16:09 AFreeMan 阅读(112) 评论(0) 推荐(0) 编辑