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

📄 12iii.cpp

📁 《C/C++程序设计导论(第二版)》一书的程序源文件
💻 CPP
字号:
// complex.cpp  Implementation file for class Complex

#include <iostream.h>
#include "complex.h"

// InputC()  Input a complex pair into owner
void Complex::InputC (istream& in)
{	char i, paren, comma;
	in >> paren >> real >> comma >> imag >> i >> paren;
}

// OutputC()  Output the owner as a complex pair
void Complex::OutputC (ostream& out)
{	out << '(' << real << ',' << imag << "i)" << endl;
}

// AddC()  Return the sum of the owner and the parameter
Complex Complex::AddC (Complex x)
{	Complex temp;
	temp.real = real + x.real;
	temp.imag = imag + x.imag;
	return (temp);
}

// SubC()  Return the diff. between the owner and parameter
Complex Complex::SubC (Complex x)
{	Complex temp;
	temp.real = real - x.real;
	temp.imag = imag - x.imag;
	return (temp);
}

// MulCt()  Return the product of  the owner and the parameter
Complex Complex::MultC( Complex x)
{	Complex temp;
	temp.real = (real*x.real) - (imag*x.imag);
	temp.imag = (imag * x.real) + (real * x.imag);
	return (temp);
}

⌨️ 快捷键说明

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