类的复数计算 出现问题了,改不过来
#include <iostream>using namespace std;
struct complex
{
double a;
double b;
};
struct tcomple
{
complex one;
complex two;
};
class tcomplex
{
private:
complex one;
complex two;
public:
void begin(tcomplex *pi,const complex& first,const complex& second);
void plus();
void minus();
void multiplies();
void divides();
};
void tcomplex::plus()
{
double addx=one.a+two.a;
double addy=one.b+two.b;
cout<<addx<<" "<<addy<<endl;
}
void tcomplex::minus()
{
double minusx=one.a-two.a;
double minusy=one.b-two.b;
cout<<minusx<<" "<<minusy<<endl;
}
void tcomplex::multiplies()
{
double multipliesx=one.a*two.a-one.b*two.b;
double multipliesy=one.b*two.a+one.a*two.b;
cout<<multipliesx<<" "<<multipliesy<<endl;
}
void tcomplex::divides()
{
double dividesx=(one.a*two.a+one.b*two.b)/(two.a*two.a+two.b*two.b);
double dividesy=(one.b*two.a-one.a*two.b)/(two.a*two.a+two.b*two.b);
cout<<dividesx<<" "<<dividesy<<endl;
}
int main(void)
{
complex first,second;
tcomplex value;
cin>>first.a>>first.b;
cin>>second.a>>second.b;
value.begin(first,second);//编译器说:error: no matching function for call to 'tcomplex::begin(complex&, complex&)'|
value.plus();
value.minus();
value.multiplies();
value.divides();
}