Complex - friend bool operator == (const Complex...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* Sample Complex number class definition. Author: Eric Van Wyk Date: March 30, 2010 */ #ifndef COMPLEX_H #define COMPLEX_H #include <iostream> using namespace std ; class Complex { public: Complex(double, double) ; Complex (double r) ; Complex (const Complex &) ; ~Complex() ; string show() const ; void addTo (Complex) ; void multiplyBy (Complex) ; bool equals(Complex) ; const Complex add(const Complex &) ; const Complex multiply(const Complex &) ; double getReal() const ; double getImag() const ; friend ostream & operator << (ostream &, const Complex &) ; // use these if "overloaded friend functions" are used. friend const Complex operator + (const Complex &, const Complex &) ; friend const Complex operator * (const Complex &, const Complex &) ;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: friend bool operator == (const Complex &amp;, const Complex &amp;) ; // use these if &quot;method overloading&quot; is used. /* const Complex operator + (const Complex &amp;c) ; const Complex operator * (const Complex &amp;c) ; bool operator == (const Complex &amp;c) ; */ private: double real ; double imag ; int id_num ; static int next_id_num ; } ; ostream &amp; operator &lt;&lt; (ostream &amp;, const Complex &amp;) ; // use these if &quot;overloaded friend functions&quot; are used. const Complex operator + (const Complex &amp;, const Complex &amp;) ; const Complex operator * (const Complex &amp;, const Complex &amp;) ; bool operator == (const Complex &amp;, const Complex &amp;) ; #endif...
View Full Document

Page1 / 2

Complex - friend bool operator == (const Complex...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online