C++ Programming Notes
C++ is a compiled language. Its source text has to be processed by a compiler, producing object files, which are combined by a linker to give an executable program.
An executable must be created for specific hardware. An executable would not be portable from PC to Mac for instance.
C++ is a statically typed language, meaning the type of every entity (e.g. object, value, name, and expression) must be known to the compiler at its point of use. The type of an object determines the set of operations applicable to it.
How to Write a C++ Program
Every C++ program must have exactly one global function named main().
The int integer value returned by main(), if any, is the program's return value to "the system". If no value is returned, the system will receive a value indicating successful completion. A nonzero value from main() indicates failure.
All executable code is placed in functions and called directly or indirectly from main().
To Open an Existing CodeBlocks Project
1. File -> Open
Needed if you want to use the Input/Output stream, i.e. get from/write to the stream.
using namespace std;
Tells the compiler that symbol names defined in the std-library namespace are to be brought into your program's scope, so you can omit the namespace qualifier, and write for example
A function cannot be called unless it has been previously declared.
A "return type" void indicates that a function does not return a value.
In a function declaration, the return type comes before the name of the function, and the argument types come after the name enclosed in parentheses.
Macros in C++
#define - The directive used to define a macro.
When the name of a macro is recognised in source code, it's treated as a call to that macro, and the macro name is replaced by a copy of the macro body.
Separate Header and Implementation Files
All Content ©2020 WebRef.eu