Tom Kelliher, CS23
Mar. 7, 1997
Use:
Complex x; Complex y(5.0); Complex z(-3.0, 2.0);
Constructor declaration:
Complex(float real = 0.0, float imag = 0.0);
Constructor definition:
Complex::Complex(float real, float imag) { ... }
Use:
Complex x(1.0); Complex y(3.0, 4.0); x.Add(y); x.Add(3.0);
Member function declarations:
void Add(complex y); void Add(float y);
Not important now, just included so you can see calls to copy constructor.
Add use:
Complex x(1.0, 2.0); Complex y(3.0, 4.0); x.Add(y);
Class declaration:
private: float re; float im;
Add definition:
void Complex::Add(Complex y) { re += y.re; im += y.im; }