2022年10月26日
摘要: #include<iostream> using namespace std; //用模板实现输出两个数当中最小的值 template<class T> T tmin( T x, T y) { return x<y?x:y; } void main() { int a = 5,b = 10; flo 阅读全文
posted @ 2022-10-26 20:28 进取 阅读(95) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; //用模板实现两个数值交换 template<class T> void tswap( T *x, T *y) { int temp = *x; *x = *y; *y = temp; } //排序模板 template 阅读全文
posted @ 2022-10-26 20:26 进取 阅读(41) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> #include<string> using namespace std; class School { protected: int Number; string Name; //c++中碰到字符数组就用string类型来定义 public: School(i 阅读全文
posted @ 2022-10-26 20:23 进取 阅读(11) 评论(0) 推荐(0) 编辑
  2022年10月25日
摘要: 在c++中,通过类可以实现数据的封装性和信息隐藏的能力,而友元函数则破坏了类的封装和信息隐藏的能力,使得类的私有属性的成员变量可以被其他类对象的方法直接访问。 #include<iostream> using namespace std; class Date; class Time { publi 阅读全文
posted @ 2022-10-25 17:04 进取 阅读(187) 评论(0) 推荐(0) 编辑
  2022年6月13日
摘要: 我们将完成特定功能的代码块放在一个.py结尾的文件中,这个文件被称为模块。在这个模块中可能包含变量,函数,类等等内容。 当我们从外部需要用到这个模块时,就需要将这个模块导入到我们当前环境。导入方式有以下几种。 import 模块 import 模块.函数 from 模块 import 函数 当被导入 阅读全文
posted @ 2022-06-13 21:46 进取 阅读(319) 评论(0) 推荐(0) 编辑