Code:
#include <iostream>
using namespace std;
static int i;
class x {
int i;
public:
x() { cout << "In HERE" << endl; }
int geti() { return i; }
};
int main()
{
cout << "Inside main() = " << ((x *)(&i+1))->geti() << endl;
*(&i+1) = 17;
cout << "Inside main() = " << ((x *)(&i+1))->geti() << endl;
static x aa;
cout << "Inside f() : " << aa.geti() << endl;
x bb;
}
I came across this code on the internet. I tried to compile it using MingGW and it compiles and works!!! I'm confused. Why? Would somebody explain this??
TIA.