WebRef.eu  - Internet Marketing and Online Business Resources  

Home / Site Map | Contact

 

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().

Getting Started with C++





To Open an Existing CodeBlocks Project

1. File -> Open
2. Change the file type filter to Code::Blocks project/workspaces files
3. Navigate to the project on disk
4. Select it
5. Click open.

 

Common Includes

#include <iostream>

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

cout

instead of

std::cout

Functions

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.

https://docs.microsoft.com/en-us/cpp/preprocessor/macros-c-cpp?view=msvc-160

Separate Header and Implementation Files

http://www.math.uaa.alaska.edu/~afkjm/csce211/handouts/SeparateCompilation.pdf

 

Visit LowPrices.co.uk for Your UK Shopping



 




Low Prices UK Shopping

Compare Prices
at LowPrices.co.uk


Home / Site Map | Contact

All Content ©2020 WebRef.eu