Hey,
I think I may be losing it...so I'm coming here...
I was playing with the snippets plugin in gedit (if you don't know what that is it doesn't matter) and just made a program using them..
The program works, fine. If I'm not mistaken, this program should blow up...but it doesn't. What gives?
Code:
#include "test.h"
int main (int argc, char const* argv[])
{
if (1 == 1)
{
MyClass* a;
int* b;
*b = 5;
a->myfunct();
printf("%i\n", *b);
delete a;
}
return 0;
}
Code:
#include <stdio.h>
class MyClass
{
public:
MyClass();
virtual ~MyClass();
void myfunct()
{
printf("Hello World\n");
}
private:
};
Output:
Code:
$ ./a.out
Hello World
5
One word: HOW? It's like creating the pointers are allocating the memory...what gives?
This is being compiled with g++ version 4.4.3.
I need somebody to tell me I'm not losing myself here...