(C++) Exceptional C++: item 20
February 24, 2017 · View on GitHub
(C++) Exceptional C++: item 20
Exceptional C++: item 20 contains the code from Exceptional C++ item 20.
///Completed from /// * Herb Sutter. Exceptional C++. ISBN: 0-201-61562-2. Item 20 #include <iostream> using namespace std; class Complex { public: Complex( double real, double imaginary = 0 ) : _real(real), _imaginary(imaginary) {}; void operator+ ( Complex other ) { _real = _real + other._real; _imaginary = _imaginary + other._imaginary; } void operator<<( ostream os ) { os << "(" << _real << "," << _imaginary << ")"; } Complex operator++() { ++_real; return *this; } Complex operator++( int ) { Complex temp = *this; ++_real; return temp; } private: double _real, _imaginary; }; int main() { }
References
- Herb Sutter. Exceptional C++. ISBN: 0-201-61562-2.