/* --- WHAT'S WRONG WITH A HARMLESS LITTLE TYPE CASTING? --- */ /* A Poem in C++ by Chuck Liang */ #include class bigobject { private: int x; double y; public: bigobject() { x = 2; y = 3.14; } double gety() { return y; } }; int main(int argc, char **argv) { bigobject *A = new bigobject(); int *x = (int*)A; double *y = (double*)((char*)A+4); cout << "The \"private\" integer is " << *x << endl; cout << "and the not-so-private double was " << *y << endl; *y += 5.86; cout << "but what I get back now reads " << A->gety() << endl; cout << "Private? Says who?\n"; return 0; }