2022年10月26日
摘要: 实现文件写入 #include<iostream> #include<fstream> using namespace std; void main() { fstream wfs("test5.txt", ios::out); if(!wfs) cout << "打开文件失败" << endl; 阅读全文
posted @ 2022-10-26 21:34 进取 阅读(18) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; void main() { // 功能: 计算 中文在内存占用的字节数 char name[] = "成都"; char node_name[] = "成都移动04节点"; cout << "int占用:" << siz 阅读全文
posted @ 2022-10-26 21:17 进取 阅读(46) 评论(0) 推荐(0) 编辑
摘要: 闰年计算方法: 能被400整除。 能被4整除,不能被100整除。 #include<iostream> using namespace std; class Sample { private: int x; public: Sample() {} Sample(int a) {x=a;} void 阅读全文
posted @ 2022-10-26 21:08 进取 阅读(43) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; const double Pi = 3.14; class Shape { public: virtual void draw() = 0; }; class Cicle:public Shape { public: v 阅读全文
posted @ 2022-10-26 21:04 进取 阅读(22) 评论(0) 推荐(0) 编辑
摘要: #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 进取 阅读(70) 评论(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 进取 阅读(14) 评论(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:47 进取 阅读(14) 评论(0) 推荐(0) 编辑
摘要: 引用 在c++中,我们有一种比传递指针更加高效的方式,那就是引用(Reference)。 引用类似于windows环境下的快捷方式,通过快捷方式和可执行程序本身都可以运行程序。 引用的定义方式类似于指针,只不过使用的 "&" 代替了 "*" 。 void main() { int a = 9; in 阅读全文
posted @ 2022-10-26 20:38 进取 阅读(28) 评论(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 进取 阅读(32) 评论(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: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) 编辑