Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(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

 

  1. Herb Sutter. Exceptional C++. ISBN: 0-201-61562-2.

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml