Chapter 0 of the Accelerated C++ book (by Koenig and Moo, reference at bottom) has provided me with an in-depth introduction of the classic Hello World C++ program in just 6 pages. As I see that there is an end of chapter exercise section and the book does not come with a solution (for good reason I guess!), I’ve decided to have a go doing these exercises and post my solutions in separate posts. Despite the book pretty much has covered it all, I would aim to include my own version of explanation for the benefit of learning and understanding. (My solution/explanation is subject to error as it’s just a scientific programming sketchbook after all!)
Although the (Hello World) program we’ve written is simple, we’ve covered a lot of ground in this chapter.
Key concepts learnt from this chapter: Hello World program; comment; #include directive; standard library vs core language; input-output stream (iostream); standard header; angle brackets; the main function; curly braces; operand type (int and std::iostream); output operator (<<); namespace (std); standard output stream (std::cout); stream manipulator (std::endl); the return statement; expression; result; side effects; operator vs operand; left-associative operator; scope; qualified name (std::cout); scope operator (::); free and non-free form structure; special string literals; escape using backslash; semicolons; expression statement; null statement.