2022年10月26日
摘要: #include<iostream.h> class mix { public: mix(); friend mix operator+(mix &c1,mix &c2); void input(); void display(); private: int m[2][3]; }; mix::mix 阅读全文
posted @ 2022-10-26 20:58 进取 阅读(88) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; class Complex { public: Complex() {real=0;imag=0;} Complex(double r,double i) {real=r;imag=i;} double get_real 阅读全文
posted @ 2022-10-26 20:48 进取 阅读(15) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; class goods { public: goods() {total =0;} void get_toal() { cout << "当前货物总量 total = " << total << endl; } doub 阅读全文
posted @ 2022-10-26 20:46 进取 阅读(16) 评论(0) 推荐(0) 编辑
摘要: 引用 在c++中,我们有一种比传递指针更加高效的方式,那就是引用(Reference)。 引用类似于windows环境下的快捷方式,通过快捷方式和可执行程序本身都可以运行程序。 引用的定义方式类似于指针,只不过使用的 "&" 代替了 "*" 。 void main() { int a = 9; in 阅读全文
posted @ 2022-10-26 20:38 进取 阅读(38) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; //用模板实现两个数值交换 template<class T> void tswap( T *x, T *y) { int temp = *x; *x = *y; *y = temp; } void main() { i 阅读全文
posted @ 2022-10-26 20:29 进取 阅读(42) 评论(0) 推荐(0) 编辑
摘要: #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:27 进取 阅读(121) 评论(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:25 进取 阅读(67) 评论(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:22 进取 阅读(13) 评论(0) 推荐(0) 编辑
  2022年10月25日
摘要: 在c++中,通过类可以实现数据的封装性和信息隐藏的能力,而友元函数则破坏了类的封装和信息隐藏的能力,使得类的私有属性的成员变量可以被其他类对象的方法直接访问。 #include<iostream> using namespace std; class Date; class Time { publi 阅读全文
posted @ 2022-10-25 17:04 进取 阅读(212) 评论(0) 推荐(0) 编辑
  2022年6月13日
摘要: 我们将完成特定功能的代码块放在一个.py结尾的文件中,这个文件被称为模块。在这个模块中可能包含变量,函数,类等等内容。 当我们从外部需要用到这个模块时,就需要将这个模块导入到我们当前环境。导入方式有以下几种。 import 模块 import 模块.函数 from 模块 import 函数 当被导入 阅读全文
posted @ 2022-06-13 21:46 进取 阅读(347) 评论(0) 推荐(0) 编辑