Complex - /* Sample Complex number class implementation....

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

View Full Document Right Arrow Icon
/* Sample Complex number class implementation. Author: Eric Van Wyk Date: March 30, 2010 */ #include <iostream> #include <sstream> #include "Complex.h" #include "Debug.h" using namespace std ; Complex::Complex(double r, double i) { if (DEBUG) cout << ". .. Standard constructor: " << r << ", " << i << " #" << next_id_num << endl ; real = r; imag = i; id_num = next_id_num ; ++ next_id_num ; } int Complex::next_id_num = 0 ; Complex::Complex (double r) { if (DEBUG) cout << ". .. Standard constructor: " << r << " #" << next_id_num << endl ; real = r; imag = 0; id_num = next_id_num ; ++ next_id_num ; } string Complex::show() const { ostringstream s; s << "(" << real << " + " << imag << "i)" << "#" << id_num ; return s.str() ; } Complex::~Complex() { if (DEBUG) cout << ". .. Destructor for: " << real << ", " << imag << ", #" << id_num << endl ; } Complex::Complex (const Complex & c) { if (DEBUG) cout << ". .. Copy constructor for : " << c.real << ", " << c.imag << " copying #" << c.id_num << " to create #"
Background image of page 1

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

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

Page1 / 3

Complex - /* Sample Complex number class implementation....

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