Example Program: Part 1
// the private real and imaginary components of the complex
float p_real, p_imaginary;
// the string (char *) representation of the complex, updated by print()
// Three different constructors:
// a constructor which takes no arguments; initializes complex to 0
complex() { p_string = NULL; p_real = 0.0; p_imaginary = 0.0; }
// a constructor which takes one argument: sets the real part, and
// makes the imaginary part 0
complex(float r) { p_string = NULL; p_real = r; p_imaginary = 0.0; }
// a constructor which takes two arguments: real and imaginary parts
complex(float r, float i) { p_string = NULL; p_real = r, p_imaginary = i; }
// destructor: deallocate memory for p_string if it was allocated
~complex() { if (p_string != NULL) delete[] p_string; }