/
dolpement
/
programming-and-algorithmization
Обзор
Документация
Войти
/
dolpement
/
programming-and-algorithmization
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
complex_prj/complex/complex.hpp
50 строк
2 KB
dolpement
programming
13 мар 2025, 21:11
13 мар 2025, 21:11
24f0ba5
Код
Авторство
О чём код?
#ifndef COMPLEX_COMPLEX_HPP #define COMPLEX_COMPLEX_HPP #include<iostream> #include<cmath> #include <sstream> #include <string> #include <limits> struct Complex { Complex() = default; explicit Complex(const double re); Complex(const double re, const double im); ~Complex() = default; Complex& operator+=(const Complex& rhs); Complex& operator-=(const Complex& rhs); Complex& operator*=(const Complex& rhs); Complex& operator/=(const Complex& rhs); Complex& operator+=(double rhs); Complex& operator-=(double rhs); Complex& operator*=(double rhs); Complex& operator/=(double rhs); std::ostream& writeTo(std::ostream& ostrm) const; std::istream& readFrom(std::istream& istrm); double re{ 0.0 }; double im{ 0.0 }; static const char leftBrace{ '{' }; static const char separator{ ',' }; static const char rightBrace{ '}' }; }; Complex operator+(const Complex& lhs, const Complex& rhs); Complex operator-(const Complex& lhs, const Complex& rhs); Complex operator*(const Complex& lhs, const Complex& rhs); Complex operator/(const Complex& lhs, const Complex& rhs); Complex operator+(const Complex& lhs, const double rhs); Complex operator-(const Complex& lhs, const double rhs); Complex operator*(const Complex& lhs, const double rhs); Complex operator/(const Complex& lhs, const double rhs); bool operator==(const Complex& lhs, const Complex& rhs); bool operator!=(const Complex& lhs, const Complex& rhs); std::ostream& operator<<(std::ostream& out, const Complex& z); std::istream& operator>>(std::istream& in, Complex& z); #endif