info

classless.cc

I think this was just a case of wondering what sort of nonsense compilers would let me get away with. Actually, that's exactly what was going on. Last modified Mar 1, 2001.

/* * silly experimentation with class casting * * by PWR <prijks@cse.nd.edu * * march 1, 2001 * */ #include <iostream> using namespace std; class foo { public: void a() { cout << "haha!" << endl; } void b() { cout << c << endl; } private: int c; }; int main(int argc, char* argv[]) { int q = 420; void* j = NULL; ((foo*)j)->a(); ((foo*)&q)->b(); return 0; }