- 博客(7)
- 收藏
- 关注
原创 函数模板的应用
#include<iostream> using namespace std; template<class WZ> WZ MAX(WZ x,WZ y) { return(x>y)?x:y; } int main() { int i1=100,i2=50; cout<<"两个数最大的为"<<MAX(i1,i2)<<endl; return 0; } 这次上机做了一下函数模板的应用,对于函...
2021-12-19 11:46:14
181
原创 运算符的重载
#include<iostream> using namespace std; class complex { public: double real; double imag; complex(double r = 0, double i = 0) { real = r; imag = i; } }; complex operator+(complex co1, complex co2) { complex temp; temp.real = co1.real * co2..
2021-12-19 10:10:01
263
原创 声明一个scorearray继承类myarray,在该类中定义一个函数,具有将输入的数从小到大进行排序的功能
#include<iostream> #include<string> using namespace std; class myarray { public: myarray(int length); ~myarray(); void input(); void display(string); void px(); protected: int* alist; int length; }; myarray::myarray(int leng) { if (...
2021-12-11 19:58:50
1152
1
原创 派生与继承
#include<iostream> using namespace std; class base { public: void setx(int i) { x = i; } int getx() { return x; } public: int x; }; class derived :public base { public: void sety(int i) { y = i; } int gety() { return y; } void.
2021-12-04 21:39:17
3879
原创 静态成员定义和对象传递
#include<iostream> using namespace std; class tstudent { static float m_classmoney; public: tstudent(float n) { symoney = n; } void initstudent(char name[]) { name[0] = 'A'; name[1] = 'B'; name[2] = 'C'; } void expendmoney(float mone.
2021-11-27 16:03:00
532
原创 创建一个score类
本次上机课的任务是创建一个score类,并利用构造函数和析构函数、调用函数等方法,完成对成绩的显示、计算和排序。这次的编程对我来说难度还是比较大的,没有编程的基础对一些程序的逻辑结构不是很理解,所以在同学的指导下还是完成了编程。在编程的过程中,对于简单的调用函数,类的创建等等没有很大问题,但其中的函数体不是很懂,在这次作业中,出现了函数名与类名相同的错误,还有忘记了变量的声明,以及对一些字符的数据类型定义错误等等,但都被及时更改。这次上机对我的最大直观感受就是c++相对于之前的C语言感觉在实现一...
2021-11-21 17:21:34
1059
原创 输出一个二维数组和其中值
#include<iostream> using namespace std; class coordinate { public: coordinate() { times = 2; cout << "coordinate construction1 called" << endl; } coordinate(int times1) { times = times1; cout << "coordinate constructio.
2021-11-12 20:59:49
1034
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人