/* ------------- On Pointers and Privacy ------------- */ /* A Poem in C++ by Chuck Liang */ using namespace std; #include class bigobject { private: int x; double y; public: bigobject() { x = 2; y = 0.3; } double gety() { return y; } }; int main(int argc, char **argv) { bigobject *A = new bigobject(); int *x = (int*)A; double *y = (double*)((char*)A+8); cout << "The \"private\" integer is " << *x << endl; cout << "Not so private, says I." << endl; *y = 3.14; cout << "and I can change y to " << A->gety() << endl; cout << "Private? Says who?\n"; return 0; } /* OUTPUT: The "private" integer is 2 Not so private, says I. and I can change y to 3.14 Private? Says who? */