This in no way is me asking for help on homework or whatever, just for the record! You don't even have to post your code if you don't want to. It is also no my own challenge, i found it somewhere and thought it sounded interesting.
Write a program that, when run, will print out its source code. This source code, in turn, should compile and print out itself.
Without the implementation file, that's not possible (to my knowledge). When it's compiled, it gets compiled into ASM and then to Machine code. ASM and C++ are not a 1:1 type conversion so the code will just about never be the same.
@ HelioS: How is that a Quine program when you hard-coded the source in a char pointer called source and then printed it. If you take the above program and delete everything except the first two and last two lines of code it will print the exact same thing.
delete everything except the first two and last two lines of code it will print the exact same thing.
Take a closer look at the string.
(Spoilers below.)
[spoiler] The string doesn't actually contain the entire source, because it would then need to contain itself. Also note that the string is actually printed twice. Once by a special interpreter, and again directly by std::cout.
[/spoiler]
c:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../libmingw32.a(main.o)(.text+0x106)
:main.c: undefined reference to `WinMain@16'
collect2: ld returned 1 exit status