Logo

Codcups

Complete C++ Programming Reference

Complete C++ Reference's

C++ Language — Developed by Bjarne Stroustrup in 1983 as an extension of C. Combines procedural and object-oriented programming.

Intro Of C++ Language

C++ is a powerful, high-performance programming language developed by Bjarne Stroustrup in 1983 as an extension of the C language. It combines the features of procedural and object-oriented programming, making it highly suitable for large-scale applications such as system/software development, game engines, real-time simulations, and embedded systems. Due to its performance and flexibility, C++ remains a foundational language in modern software development.

Why C++ Matters? Used in game development (Unreal Engine), operating systems, browsers, and high-frequency trading systems.

Basic C++ Program Structure

#include <iostream>
using namespace std;

int main() {
    cout << "Hello, C++!" << endl;
    return 0;
}
Key Differences from C:

1. C++ Keywords

Complete List of C++ Keywords 63+
KeywordDescription
autoDeduces type automatically
boolBoolean data type
breakExit from loop or switch
caseLabel in a switch statement
catchHandles exceptions
charCharacter data type
classDeclares a class
constDeclares a constant
continueSkips current loop iteration
defaultDefault label in switch
deleteDeallocates memory
doStarts do-while loop
doubleDouble precision float
elseElse branch of if-statement
enumDeclares enumeration
explicitUsed to avoid implicit conversions
exportUsed for exporting templates
externDeclares external linkage
falseBoolean false value
floatFloating point data type
forLoop structure
friendGrants access to private members
gotoJumps to labeled statement
ifConditional branch
inlineSuggests inlining function
intInteger data type
longLong integer
mutableAllows member to be modified in const obj
namespaceEncapsulates identifiers
newAllocates memory
operatorOverloads operator
privatePrivate access specifier
protectedProtected access specifier
publicPublic access specifier
registerRegisters variable (hint)
reinterpret_castCasts pointer to different type
returnReturns from a function
shortShort integer
signedSigned modifier
sizeofReturns size in bytes
staticStatic lifetime
structDeclares structure
switchMulti-way branch
templateDeclares templates
thisPointer to current object
throwThrows exception
trueBoolean true value
tryStarts exception handler
typedefCreates alias for type
typeidReturns type information
typenameIndicates type name in templates
unionDeclares union
unsignedUnsigned modifier
usingImports names from namespace
virtualDeclares virtual function
voidNo return value or type
volatilePrevents optimization
wchar_tWide character type
whileLoop with condition at top
static_castPerforms explicit conversion
dynamic_castSafely casts in polymorphic class hierarchy

2. C++ Data Types

Basic Data Types
TypeDescription
intInteger
charCharacter
floatFloating point
doubleDouble precision float
boolBoolean (true/false)
voidNo value
wchar_tWide character
shortShort integer
longLong integer
unsignedPositive-only integer variants
// Data type examples
int age = 25;
float price = 99.99f;
double pi = 3.14159265359;
bool isDone = true;
char grade = 'A';
wchar_t wideChar = L'न';

3. C++ Operators

C++ Operators Reference
Operator TypeOperators
Arithmetic+ - * / %
Assignment= += -= *= /= %=
Increment/Decrement++ --
Comparison== != > < >= <=
Logical&& || !
Bitwise& | ^ ~ << >>
Compound Assignment&= |= ^= <<= >>=
Ternary? :
Scope Resolution::
Member Access. ->
Pointer* &
Type Caststatic_cast, dynamic_cast, const_cast, reinterpret_cast

Scope Resolution (::)

Access global variables, namespace members, or static class members

Type Casting

static_cast, dynamic_cast, const_cast, reinterpret_cast

Member Access

. for direct, -> for pointer member access

4. Modifiers

Type Modifiers
ModifierDescription
signedCan hold negative and positive
unsignedOnly positive values
shortReduces memory usage
longExtends memory size

5. Control Structures

Flow Control
StructureDescription
if / elseConditional logic
switchMulti-case logic
forLoop with init-condition-update
whileEntry-controlled loop
do...whileExit-controlled loop
breakExit loop/switch
continueSkip current iteration
gotoJumps to labeled location
returnExits function

6. Preprocessor Directives

Preprocessor Commands
DirectiveUse
#includeInclude header files
#defineDefine macros
#undefUndefine macros
#ifdefIf defined
#ifndefIf not defined
#endifEnds conditional directive
#if / #elseConditional compilation
#pragmaSpecial compiler instructions
#errorThrows compilation error
#lineChanges line number for errors

7. Special Symbols & Characters

Special Characters
SymbolMeaning
{ }Block of code
[ ]Array brackets
( )Function call or grouping
;Statement terminator
" "String literal
' 'Character literal
\\Escape character
//Single-line comment
/* */Multi-line comment
C++ OOP Features:

Back to Notes Page