Hi,
I have been playing around with pointers and made a little mistake of this type:
class D{
public:
int a;
};
int main()
{
D *x; //As you can see I didn't allocate memory at all...
x->a=3; // ... but initialized a member variable
cout<<x->a<<endl;
return EXIT_SUCCESS;
}
I get run-time error if compiled in DEVC++.
But I tried the same in Code::Blocks, and it works, as if I regularly allocated memory before initializing... hm... what?
Can anyone explain me this behaviour, I know some rules differ from compiler to compiler, but what's the matter with this one?
Thanks!