// -*- coding: utf-8 -*- // Time-stamp: // Implémentation naïve des nombres complexes #ifndef COMPLEX_H #define COMPLEX_H #include using namespace std; // Fonctions mathématiques : sqrt, ... #include class complex { // Fonctions amies friend std::ostream& operator<<(std::ostream&, complex z); public: // Constructeurs complex(double r = 0, double i = 0) : re(r), im(i) {} // Operateurs complex operator+=(complex& z); complex operator*=(complex& z); complex operator+(complex& z); complex operator*(complex& z); // Norme double norm() { return sqrt(re*re + im*im); } private: double re; // Partie réelle double im; // Partie imaginaire }; #endif