The first program in a new language should always be "Hello world!". 1 2 // Hello World Application 3 #include <iostream.h> The source for this example is in HelloWorld.cpp which is attached to the bottom of this page. You might think that this is the shortest C++ program that you can have - It is not! The shortest valid C++ program is: main() { } There is no need for libraries, as there is no input/output, there is no need to specify a return type for the
There are several C++ compilers that you can use for this course. Once the compiler is ANSI compliant there should be no issue in using it with this module as we just require a standard non-windowing compiler. A Unix/Linux compiler will also work. The current recommended compilers are Eclipse CDT and Codeblocks. - If you have not programmed in C++ before I would recommend Codeblocks - If you have programmed in C++ before I would recommend Eclipse CDT CodeblocksThe Codeblocks IDE is available at: http://www.codeblocks.org/. It is is a full-featured Integrated Development Environment (IDE) for the C/C++ programming language. If you wish you can use the Mingw port of GCC (GNU Compiler Collection) as its compiler. There is a version of Codeblocks for Linux and Mac as well as for Windows. Download the version with the name something like "codeblocks-12.11mingw-setup.exe" where you also install the MINGW compiler. If you have previously installed the compiler there is no need to do that. Eclipse CDT"The CDT Project provides a fully functional C and C++ Integrated Development Environment based on the Eclipse platform. Features include: support for project creation and managed build for various toolchains, standard make build, source navigation, various source knowledge tools, such as type hierarchy, call graph, include browser, macro definition browser, code editor with syntax highlighting, folding and hyperlink navigation, source code refactoring and code generation, visual debugging tools, including memory, registers, and disassembly viewers." - http://www.eclipse.org/cdt/Figure 2. The Eclipse CDT Integrated Development Environment (IDE) ____ [6] Preprocessor directives are orders for the preprocessor, not for the program itself. They must be specified in a single line of code and should not end with a semicolon. These notes are copyright Dr. Derek Molloy, School of Electronic Engineering, Dublin City University, Ireland 2013-present. Please contact him directly before reproducing any of the content in any way. |