⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 复数计算.txt

📁 铁道出版社出版的C++的习题源代码
💻 TXT
字号:
#include<iostream.h>
class Complex
{
public:
   Complex(){real=0;imag=0;}
   Complex(double r,double i){real=r;imag=i;}
   Complex complex_add(Complex &c2);
   void display();
private:
    double real;
    double imag;
};
Complex Complex::complex_add(Complex &c2)
{
    Complex c;
    c.real=real+c2.real;
    c.imag=imag+c2.imag;
    return c;
}
void Complex::display()
{
  cout<<"("<<real<<","<<imag<<"i)"<<endl;
}
void main()
{
   Complex c1(3,4),c2(5,-10),c3;
   c3=c1.complex_add(c2);
   cout<<"c1=";c1.display();
   cout<<"c2=";c2.display();
   cout<<"c1+c2=";c3.display();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -