重新认识c++(01),做个简单的复数Complex类(二)

2014-11-24 10:20:28 · 作者: · 浏览: 1
le a){ Complex r(a) ; return (*this)-r; } Complex Complex::operator * (double a){ Complex r(a) ; return (*this)*r; } Complex Complex::operator / (double a){ Complex r(a) ; return (*this)/r; } ostream& operator << (ostream &out,Complex &c){ double a = c.getA() ; double b = c.getB() ; if(a == 0 ) { if(b==0)out<<0; else out< 0)out<

Main.cpp文件

#include 
     
      
#include "Complex.h"
using namespace std;

int main()
{
    Complex a(1,2);
    Complex b(2,3);
    cout<
      
       
测试结果:




可能写的仓促,没有想到的功能。逐渐完善。