#include using namespace std; class Complex { private: double re, im; public: Complex( double r, double i ) : re( r ), im( i ) { // empty constructor } double real() const { if ( this == 0 ) { return 0.0; } else { return re; } } double imag() const { return im; } }; int main() { Complex * z = new Complex( 3, 5 ); cout << "Re(z) = " << z -> real() << endl; cout << "Im(z) = " << z -> imag() << endl; delete z; z = 0; cout << "Re(z) = " << z -> real() << endl; cout << "Im(z) = " << z -> imag() << endl; return 0; }