首页 > 其他 > 详细

课堂测试

时间:2019-04-01 18:26:52      阅读:116      评论:0      收藏:0      [点我收藏+]

#include <iostream> #include <cmath> using namespace std; class complex{ public: complex(double real1=0,double imaginary1=0); complex(complex &t); void add(complex a); void show(); double mod(); private: double real; double imaginary; }; complex::complex(double real1,double imaginary1){ real=real1; imaginary=imaginary1; } complex::complex(complex &t){ real=t.real; imaginary=t.imaginary; } void complex::add(complex a){ real=real+a.real; imaginary+=a.imaginary; } void complex::show(){ cout<<real<<"+"<<imaginary<<"i"<<endl; } double complex::mod(){ cout<<sqrt(real*real+imaginary*imaginary)<<endl; } int main() {complex c1(3,5); complex c2(4.5); complex c3(c1); c1.add(c2); c1.show(); c1.mod(); return 0; }

技术分享图片

课堂小结:在第一个complexcomplex那里,因为少写了两个1,所以卡了很久,不过在同学的帮助下明白了原因。

 

https://www.cnblogs.com/0122Frank/p/10587023.html#4219744

https://www.cnblogs.com/sqcmxg/p/10574927.html

https://www.cnblogs.com/csl-40/p/10583521.html

课堂测试

原文:https://www.cnblogs.com/elise00/p/10637773.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!