上一页 1 2 3 4 5 6 7 ··· 33 下一页
摘要: 可变整型数组 查看代码 #include <cstdio> #include <iostream> #include <cstdlib> #include <cstring> #include <algorithm> #include <cmath> using namespace std; cla 阅读全文
posted @ 2022-03-04 14:12 liankewei123456 阅读(34) 评论(0) 推荐(0) 编辑
摘要: c++/oop 运算符重载 重载为普通函数 #include <cstdio> #include <iostream> #include <cstdlib> #include <cstring> #include <algorithm> #include <cmath> using namespac 阅读全文
posted @ 2022-03-03 17:30 liankewei123456 阅读(43) 评论(0) 推荐(0) 编辑
摘要: 常类型 常对象 类名 const 对象名 const 类名 对象名 必须进行初始化 常数据成员 定义的时候一定要用成员初始化列表来初始化 class A{ public: const int v; A (int x=0):v(x){} // A (int x=0){v=x;} Wrong }; in 阅读全文
posted @ 2022-03-03 08:51 liankewei123456 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 分为友元函数和友元类两种 友元函数 friend 函数类型 友元函数名(参数表) (1)友元函数不是成员函数,在类中声明,在类外定义 (2)友元函数的声明可以放在类中的任意一个位置,不受访问权限限制 (3)友元函数可以访问类的 private 成员 成员函数声明为友元函数 friend 函数类型 类 阅读全文
posted @ 2022-03-02 22:59 liankewei123456 阅读(54) 评论(0) 推荐(0) 编辑
摘要: 对象指针 指向一个对象 写法 p->sum() 和 (*p).sum() 是等价的,前者更加直观些 #include <cstdio> #include <iostream> #include <cstdlib> #include <cstring> #include <algorithm> #in 阅读全文
posted @ 2022-02-27 15:32 liankewei123456 阅读(65) 评论(0) 推荐(0) 编辑
摘要: CS61A python 字符串 str(1) = '1' 把数字等转化为字符串 + : 连接字符串 print(f"Debuting at #{place}: '{song}' by {artist}") artist = "Lil Nas X" song = "Industry Baby" pl 阅读全文
posted @ 2022-02-26 15:31 liankewei123456 阅读(42) 评论(0) 推荐(0) 编辑
摘要: C++/oop 指针 按理说指针不是c++特有的东西,只是我恰好发现自己不太会,赶紧补一下 int *p 定义指针 p 指向 int 型变量 以下写法均可 int* p / int * p p = &a (& 取地址) 指针本身的类型是 unsigned long int *p 取内容 指针保存着变 阅读全文
posted @ 2022-02-26 09:35 liankewei123456 阅读(64) 评论(0) 推荐(0) 编辑
摘要: 面向对象 简单的说就是写很多类 每个类有自己的数据和函数,叫做“成员”。 类定义出来的变量,也称为类的实例,就是“对象”。 和struct 好像差不多 对象之间有 '=' 关系,其他的需要定义 private: 私有成员,只能在成员函数内访问public: 公有成员,可以在任何地方访问protect 阅读全文
posted @ 2022-02-25 19:52 liankewei123456 阅读(36) 评论(0) 推荐(0) 编辑
摘要: c++/oop 引用 就相当于是原变量 int & a = b 相当于是别名 一个神奇的写法:引用作为函数返回值 1 int n = 4; 2 int & SetValue() { 3 return n; 4 } 5 int main() { 6 SetValue() = 40; 7 cout << 阅读全文
posted @ 2022-02-25 19:03 liankewei123456 阅读(26) 评论(0) 推荐(0) 编辑
摘要: CS61A pyhton 高阶函数 A function that either: Takes another function as an argument Returns a function as its result All other functions are considered fi 阅读全文
posted @ 2022-02-25 10:50 liankewei123456 阅读(43) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 33 下一页