Example Program: Part 3
// Note, this is an example of where using C++ streams (<< and >>)
// would be really nice, but we'll save that for a later example.
char *complex::print(void)
{
if (p_string == NULL)
p_string = new char[30];
sprintf(p_string, "%.2f%+.2fi", p_real, p_imaginary);
return p_string;
}
Previous slide
Next slide
Back to first slide
View graphic version