On all future code related posts, for all full working code examples, I’ll be provided a link to the Ideone online code editor. It’s a little like pastebin but with the bonus of allowing you to both fork and compile the code online.
I have, on a number of occasions, toyed with the idea of using Github for this but to make it practical I’d need a separate repository for each article and that is likely to be come quite a hefty number of repos to look after. I did, at one point, try using one repository but that doesn’t work very well because you then either have to have separate branches for each article (which doesn’t make a huge amount of sense) or use one branch and rely on tagging. Both felt very clumsy because this isn’t really what a VCS (Version Control System) was designed for. On the other hand, Ideone is perfect as it is specifically designed for providing small working example code snippets. The fact you can fork my examples and then play with them is an added bonus!
To make it nice an easy to figure out when and where there is an Ideone example to play with I’ll add a click-able Ideone icon immediately following the source code in the blog post. You’ll be able to click on this and, immediately, start playing. I would ask one small favour – if, whilst playing, you find any defect in my original example I would really appreciate you letting me know. I’ll be sure to add an errata to the blog post and credit you (unless you ask me not to) with being the person who found and fixed the problem.
Anyway, to get us started – here is a small “hello, world!” example.
using namespace std;
cout << "Hello, world!" << endl;