示例#1
0
ComplexCalculator ComplexCalculator::Add(ComplexCalculator first,
                                         ComplexCalculator second) {
    ComplexCalculator temp(0, 0);
    temp.real = first.GetReal()+second.GetReal();
    temp.imaginary = first.GetImaginary()+second.GetImaginary();
    return temp;
}
ComplexCalculator ComplexCalculator::Div(ComplexCalculator first, ComplexCalculator second)
{
	ComplexCalculator temp(0,0);
	temp.real=(first.GetReal()*second.GetReal()+first.GetImaginary()*second.GetImaginary())/(second.GetReal()*second.GetReal()+second.GetImaginary()*second.GetImaginary());
	temp.imaginary=(first.GetImaginary()*second.GetReal()-first.GetReal()*second.GetImaginary())/(second.GetReal()*second.GetReal()+second.GetImaginary()*second.GetImaginary());
	return temp;
}