实验5 类和对象实验报告(8)

发布时间: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<<"

实验5 类和对象实验报告(8).doc 将本文的Word文档下载到电脑

精彩图片

热门精选

大家正在看

× 游客快捷下载通道(下载后可以自由复制和排版)

限时特价:7 元/份 原价:20元

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219