2021年10月13日

摘要: 1. 直接存取和间接存取 2. 指针基类型 3. 函数指针和返回指针的函数 指针函数:指向函数的指针变量 函数指针:返回值为指针的函数 函数指针和返回指针的函数 4. 阅读全文
posted @ 2021-10-13 22:45 祁东 阅读(20) 评论(0) 推荐(0) 编辑

2021年10月12日

摘要: 补充: 1. 析构函数: 1.1 派生类指针操作派生类对象,基类析构函数不是虚函数,此时会先释放派生类的资源,再释放基类的资源,这里资源就不会出现泄漏的情况。 1.2 基类指针操作派生类对象,基类析构函数不是虚函数:此时只是释放了基类的资源,而没有调用派生类的析构函数,这样的删除只能够删除基类对象, 阅读全文
posted @ 2021-10-12 12:44 祁东 阅读(18) 评论(0) 推荐(0) 编辑

2021年10月11日

摘要: 补充: 构造函数:一种特殊的成员函数,不能声明为const 的 常量指针this:this类型为“A *const”,总是指向调用成员函数的“这个”对象; const成员函数:用于修改隐式this指针的类型,修改后this指针类型为“const A *const”。相当于为this指针增加了“底层c 阅读全文
posted @ 2021-10-11 22:55 祁东 阅读(20) 评论(0) 推荐(0) 编辑

2021年10月10日

摘要: 1. 调用全局变量: (::global) 2. 静态函数和静态变量 class Test { private: static int val; int a; public: static int func(); void sfunc(Test& r); }; int Test::val = 200 阅读全文
posted @ 2021-10-10 14:44 祁东 阅读(27) 评论(0) 推荐(0) 编辑

2021年10月9日

摘要: 1. delete 和 new 2. 函数重载 3. 内联函数 4. 常量 5. 引用 常量引用 int x = 1; const int& y = x; x = 2; cout << y << endl; /*output 2 */ 函数引用 int& func2(int* pint) { ret 阅读全文
posted @ 2021-10-09 23:04 祁东 阅读(29) 评论(0) 推荐(0) 编辑
 
摘要: 汉诺塔 - 递归 #include <iostream> #include <cstring> #include <string> #include <iomanip> #include <windows.h> #include <ctime> using namespace std; int co 阅读全文
posted @ 2021-10-09 23:04 祁东 阅读(15) 评论(0) 推荐(0) 编辑

2021年10月8日

摘要: 1. sizeof 和 strlen sizeof:得到类型长度 strlen:得到字符串不包含 '\0' 的长度 2. 静态局部变量和全局变量自动初始化为 0;自动变量不初始化时,为随机值;局部变量不初始化时,不会自动初始化局部变量初始化 3. 不同函数里面的静态变量可以同名 阅读全文
posted @ 2021-10-08 21:17 祁东 阅读(11) 评论(0) 推荐(0) 编辑
 
摘要: 函数指针查找剩余子串 char* match(char* ch, char c); int main() { char ch[50], c, * p; int pos = 0; cin.getline(ch, 20); cin >> c; p = match(ch, c); if (p) { pos 阅读全文
posted @ 2021-10-08 21:17 祁东 阅读(26) 评论(0) 推荐(0) 编辑

2021年10月7日

摘要: 1. 二维数组与指针 *(a+i):一维数组的首地址 a+i:第 i 行的地址,即&a[i] &a+1:移动整个数组 a 的字节数 int ** Ptr <==> int Ptr[ x ][ y ]; int *Ptr[ 5 ] <==> int Ptr[ 5 ][ x ]; int ( *Ptr 阅读全文
posted @ 2021-10-07 22:18 祁东 阅读(16) 评论(0) 推荐(0) 编辑
 
摘要: 获取系统时间 int main() { time_t now; struct tm local; while (1) { time(&now); localtime_s(&local, &now); cout.fill('0'); cout << local.tm_hour << ":"; cout 阅读全文
posted @ 2021-10-07 22:18 祁东 阅读(16) 评论(0) 推荐(0) 编辑