C++: The Complete
Reference
A condensed personal reference covering all core concepts — from the C
foundation through advanced C++ and the Standard Template Library.
PART I — FOUNDATION
1. Overview of C
C++ is built entirely on C. Every valid C program (C89) is also a valid C++
program. Understanding C is essential to mastering C++.
Key Characteristics of C
Middle-level language — combines high-level structure with low-
level memory access (bits, bytes, addresses)
Structured — compartmentalizes code through functions and code
blocks using {}
Portable — programs can be moved between platforms with
minimal changes
, Not strongly typed — allows most type conversions freely
No runtime bounds checking — the programmer is responsible
Program Structure
int main(void) {
!" program starts here
return 0;
}
return_type function_name(param_list) {
!" function body
}
NOTE
C uses Ele extensions .c ; C++ uses .cpp . The C subset of C++ is deEned
by C89 (32 keywords). C99 added 5 more but C++ uses C89 as its base.
2. Data Types & Variables
Five Basic Types
TYPE DESCRIPTION TY P ICA L S IZ E MI N RA N GE
char Character 8 bits -127 to 127
int Integer 16 or 32 bits -32,767 to 32,767
float Floating-point 32 bits 6 digits precision
double
, Double Roat 64 bits 10 digits precision
void No type / generic — —
C++ adds bool and wchar_t . ModiEers: signed , unsigned , short ,
long .
Variable Scope
L OC AL GLOBAL
Inside a block Outside all functions
Created on entry, destroyed on exit. Persists entire program. Auto-
No default value. initialized to 0.
F OR MA L PARA M
Function arguments
Act like local variables inside the
function.
Storage Class Specifiers
SPECIF IE R MEANING
auto Default for local vars (rarely used explicitly)
extern Declares a variable deEned elsewhere (multi-Ele programs)
static Local: retains value between calls. Global: Ele-scope only.
register Hint to store in CPU register for speed (int/char only e^ective)
Qualifiers
, const int a = 10; !" cannot be changed by program
volatile int port; !" may change by external means, don't optimize
const volatile char *p; !" hardware port: read-only by program, changes exter
Constants
int hex = 0x80; !" 128 decimal (0x prefix = hex)
int oct = 012; !" 10 decimal (leading 0 = octal)
long x = 35000L; !" L suffix = long
float f = 1.5F; !" F suffix = float
unsigned u = 100U; !" U suffix = unsigned
ESCAPE SEQ U ENC E S
CODE MEANING CO D E M EAN I NG
\n Newline \t Tab
\r Carriage return \b Backspace
\\ Backslash \" Double quote
\0 Null \a Alert (bell)
typedef
typedef float balance; !" balance is now an alias for float
balance over_due; !" same as: float over_due;
3. Operators & Expressions