class Complex{ public:Complex();~Complex();Complex(double a, double b) //конструктор с параметрами{this->re = a; this->im = b;}double re,im; //действительная мнимаяdouble mo,gr; //модуль градусы//QString ComplexPrint(Complex a);Complex operator+(Complex a) // перегрузка оператора{ Complex rez; rez.im =im +a.im; rez.re = re+ a.re; return rez;}};
inline const QPoint operator+(const QPoint &p1, const QPoint &p2){ return QPoint(p1.xp+p2.xp, p1.yp+p2.yp); }
C++ (Qt)public: Complex() {} ~Complex() {}...
C++ (Qt)#include <complex>#include <iostream> using namespace std; int main() { complex<double> c1(1.0, 2.0); complex<double> c2 = c1; c2 += 1.0; cout << c1 << endl; cout << c2 << endl; return 0;}
Complex operator + (const Complex& c1, const Complex& c2){ return Complex(c1.re + c2.re, c1.im + c2.im);}
Complex operator + (const Complex& c) const{ return Complex(re + c.re, im + c.im);}
Class operator + (Class second) { this->im += second.im; this->re += second.re; return *this;}