Well for me, writing it in three separate files as in my post above and compiling it with the command line as above works fine. If you do the exact same thing and it doesn't work, the problem is not with the code.