Quote Originally Posted by Werpd View Post
Heh, thanks. But it was more of a test than a question.
I need you to explain why it's working and doing what it does.
And what if I have a compiler where this code doesn't "work"? Do I need to explain that also?

You have constructs in C++ that are considered "undefined behaviour" (UB). The code you have is UB, and there is no need to explain anything. That code could run on that compiler using a certain option, and crap out if another compiler option is used. Someone could develop a compiler that could detect code as you've posted, and just issue a diagnostic that the program cannot continue when you run the code.

C++ isn't like any of the other languages, where bad code automatically produces a diagnostic, i.e. similar to Java or C#. Bad code in C++ (or C) means your program can do anything in particular, including run successfully or crash and burn right away.

Regards,

Paul McKenzie