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

📄 complex.h

📁 斯坦福Energy211/CME211课《c++编程——地球科学科学家和工程师》的课件
💻 H
字号:
// This is the header file for the Complex class.  The// implementation is in a separate file.// Any code that uses the Complex class must include this// file, using the preprocessor directive//// #include "complex.h"//// The implementation file must use this directive as well.#include <iostream>#ifndef CLASS_COMPLEX#define CLASS_COMPLEX// Declaration of Complex class, for working with complex// numbers as easily as with doublesclass Complex {public:	// Constructors	Complex( double re = 0.0, double im = 0.0 );	Complex( const Complex& z );		// Destructor	~Complex();	// Extract real and imaginary parts	double Re() const;	double Im() const;		// These are the polar coordinates of the	// complex number: z=a+bi=r*exp(it) where	// r=|z|=sqrt(a^2+b^2), tan(b/a)=t	// Abs() returns the modulus r 	// Arg() returns the argument t	double Abs() const;	double Arg() const;			// Complex conjugate a-bi, where z=a+bi	Complex Conj() const;		// Overloads of arithmetic operators	Complex operator-() const; // unary minus	Complex operator+( const Complex& z ) const;	Complex operator-( const Complex& z ) const;	Complex operator*( const Complex& z ) const;	Complex operator/( const Complex& z ) const;		Complex operator+( double x ) const;	Complex operator-( double x ) const;	Complex operator*( double x ) const;	Complex operator/( double x ) const;		// Overloads of assignment operators	Complex& operator=( const Complex& z );	Complex& operator+=( const Complex& z );	Complex& operator-=( const Complex& z );	Complex& operator*=( const Complex& z );	Complex& operator/=( const Complex& z );		Complex& operator=( double x );	Complex& operator+=( double x );	Complex& operator-=( double x );	Complex& operator*=( double x );	Complex& operator/=( double x );		// For conversion to double (ignores imaginary part)	operator double() const;		static double Tol;	private:	// Private data members store the real and	// imaginary parts of this complex number	double m_re;	double m_im;} ;// For these operators, a Complex object is not the first// argument, so they must be declared outside the classComplex operator+( double x, const Complex& z );Complex operator-( double x, const Complex& z );Complex operator*( double x, const Complex& z );Complex operator/( double x, const Complex& z );std::ostream& operator<<( std::ostream& out, const Complex& z );std::istream& operator>>( std::istream& in, Complex& z );#endif

⌨️ 快捷键说明

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