实验5 类和对象实验报告(8)
发布时间:2021-06-06
发布时间:2021-06-06
五、创建一个名为Complex的类,进行复数的算术运算。编写一个测试程序来测试该类。
#include<iostream>
using namespace std;
class Complex
{
private:
double x1,y1,x2,y2;
public:
Complex(){x1=1;y1=1;x2=1;y2=1;}
Complex(int a,int b,int c,int d){x1=a;y1=b;x2=c;y2=d;}
Void jia(){ cout<<"加:("<<x1<<","<<y1<<")+("<<x2<<","<<y2<<")="<<"("<<x1+x2<<","<<y1+y2<<")"<<endl; }
void jian(){ cout<<"减:("<<x1<<","<<y1<<")-("<<x2<<","<<y2<<")="<<"("<<x1-x2<<","<<y1-y2<<")"<<endl; }
void chen(){ cout<<"乘:("<<x1<<","<<y1<<")*("<<x2<<","<<y2<<")="<<"("<<(x1*x2-y1*y2)<<","<<(x1*y2+y1*x2)<<")"<<endl;}
void chu(){ cout<<"
上一篇:《旅游策划学》旅游路线设计例子
下一篇:英语四级段落翻译训练资料