设计一个程序,将加法运算功能重载为友员成员函数,使之能够实现复数的加法运算。
设计一个程序,将加法运算功能重载为友员成员函数,使之能够实现复数的加法运算。
3 4
5 6
c1=(3, 4i)
c2=(5, 6i)
c3=(8, 10i)
#include<iostream> using namespace std; class Complex { public: Complex() { real=0;imag=0; } Complex(double r,double i) { real=r; imag=i; } friend Complex complex_add(Complex &c1,Complex &c2); void display(); private: double real; double imag; }; //pdsu-c1 //pdsu-c1 int main() { //pdsu-c2 //pdsu-c2 return 0; }
注意,复数输出时,逗号后有1个空格
Anything about this OnlineJudge, Please Contact Administrator. Click add QQ
OJ system based on HUSTOJ Project , UI based on Twitter Bootstrap
Copyright 2016 ACM算法攻关部cnt: 4429
关于网站改版