Show Menu
Cheatography

C++ Basics Cheat Sheet (DRAFT) by

Beginning C++

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Integrated Develo­pment Enviro­nment (IDE)

The Editor
Provides an intera­ctive enviro­nement in which to create and edit C++
The Compiler
Converts source code into object code
The Linker
Does 3 things
 
1. Combines various modules generated by the compiler from source code files
 
2. Adds required code modules from program libraries that are provided by C++
 
3. Welds everything into a .exe file
The Libraries
A collection of prewritten routines that can be incorp­orated into programs to carry out common operations

Program Structure

//
Two slashes indicate a single line comment
/* multi line comments */
Use / / to do several lines of comments in program
#include
Is called a directive
<io­str­eam>
<io­str­eam> is a header file
int
is a function type
main
the name of the function
( )
could include parameters
{
the beginning of main's function definition
std::cout
standard character output device (usually the screen)
<<
insertion operator - indicates what follows is inserted into the std::cout
"­Hello World!­"
the content inserted into std::cout
;
The end of the statement
 
std::cout << "­Hello World"; is a statement
}
the end of main's function definition
// Name of program
// Program name
// What program does

#include <io­str­eam>

int main()
{
std::cout << "­Hello World!­";
}

#include and Header Files

#include
is a prepro­cessor directive, it directs the compiler to do something
<io­str­eam>
Contains the defini­tions so you can use the input and output statements
"­ios­tre­am"
Using quotes tells the compiler to search in the directory where the source file is located first

Using Declar­ation and Namespaces

Standard library
An extensive set of routines that have been written to carry many common tasks
Namespace
Is a fail safe so you don't name your functions the same as prepro­grammed routines