complex.h
来自「压缩包里有教材<<C++模式设计-基于QT4开源跨平台开发框架>」· C头文件 代码 · 共 34 行
H
34 行
#include <iostream>using namespace std;/** A pair of double, <re, im> where re is the "real" coordinate and im is the "imaginary" coordinate. Mathematically, we think of this pair as representing the expression re + im*sqrt(-1) */class Complex { // binary non-member friend function declarations friend ostream& operator<<(ostream& out, const Complex& c); friend Complex operator-(const Complex& c1, const Complex & c2); friend Complex operator*(const Complex& c1, const Complex & c2); friend Complex operator/(const Complex& c1, const Complex & c2); public: Complex(double re = 0.0, double im = 0.0); // binary member function operators Complex& operator+= (const Complex& c); Complex& operator-= (const Complex& c); Complex operator+(const Complex & c2); /* This hould be a non-member friend like the other non-mutating operators. */ private: double m_Re, m_Im;};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?