#include <iostream>
using namespace std;
class Complex
{
double real, imag;
public:
Complex();
Complex(double r, double i);
Complex plus(const Complex&);
Complex minus(const Complex&);
Complex multiply(const Complex&);
double getreal();
double getimag();
void print();
};
Complex::Complex() {}
Complex::Complex(double r, double i)
:real(r), imag(i) {}
Complex Complex::plus(const Complex& second)
{
return Complex(real + second.real, imag + second.imag);
}
Complex Complex::minus(const Complex& second)
{
return Complex(real - second.real, imag - second.imag);
}
Complex Complex::multiply(const Complex& second)
{
return Complex(real * second.real - imag * second.imag,
real * second.imag + imag * second.real);
}
double Complex::getreal()
{
return real;
}
double Complex::getimag()
{
return imag;
}
void Complex::print()
{
cout << real << '+' << imag << 'i';
}
的主函式怎么寫????????
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/82093.html
標籤:C++ 語言
上一篇:C++代碼作業請求幫助!!!
下一篇:檔案新建失敗的問題
