C++教程:C++操作符的重载

2020-01-06 12:35:05王旭

}
//main.cpp
#include "complex.h"
#include <iostream.h>//由于VC编译器存在问题,这里使用标准的写法无法通过编译
int main()
{
   Complex a(3,2),b(5,4),c(1,1),d(4,2),temp;
   temp=a+b;
   temp.display();
   cout <<endl;
   temp=a-b;
   temp.display();
   cout <<endl;
   temp=a+b-(c+d);
   temp.display();
   cout <<endl;
   return 0;
}

运行结果: