C++ Lessons
- Chapter 0. Introduction. Getting Started
- Chapter 1. C++ Basics
- Chapter 2. Variables and Basic Data Types in C++
- Chapter 3. Operators in C++
- Chapter 4. Scope and Other Variable Types in C++
- Chapter 5. Code Execution Order in a Program. Loops and Branching in C++
- Chapter No. 6. Arrays, Strings, Pointers, and References in C++
- Chapter 7. Functions in C++
- Chapter 8. OOP Basics in C++
- Chapter 9. Operator Overloading in C++
- Chapter 10. Introduction to Object Relationships in C++
- Chapter 11. Inheritance in C++
- Chapter 12. Virtual Functions in C++
- Chapter No. 13. Templates in C++
- Chapter 14. Exceptions in C++
- Chapter 15. Smart Pointers and Move Semantics in C++
- Chapter 16. The Standard Template Library (STL) in C++
- Chapter No. 17. std::string in C++
- Chapter 18. Input/Output in C++
- Additional lessons
- The finale
- Step-by-step game development in C++/MFC
- C++ Practical Exercises
- SFML Graphics Library Tutorials
The C++ language (pronounced “C plus plus” ) was developed by Bjarne Stroustrup at AT&T’s Bell Labs as a complement to the C language. C++ added many new features to C. Its popularity was due to the language’s object-oriented nature. Today, C++ is widely used in software development, making it one of the most popular programming languages. It is used to create operating systems, various applications, device drivers, games, and more.
Some of the most popular software written in (or using) C++ include the MySQL database management system, the Mozilla Firefox web browser, and most Microsoft software: Windows operating systems, the Visual Studio IDE, Internet Explorer, and Microsoft Office. Adobe Photoshop, Adobe Illustrator, and Adobe Premiere Pro are written entirely in C++. This language also underlies the Unity game engine.
Here you’ll find over 240 free lessons covering the fundamentals and subtleties of C++ and programming in general from scratch. There are step-by-step tutorials on creating C++ games using the MFC and SFML libraries, and over 70 practical exercises to test your programming skills.
Chapter 0. Introduction. Getting Started
Lesson #1: Introduction to Programming
Lesson #2: Introduction to the C and C++ Programming Languages
Lesson #3: Introduction to Software Development
Lesson #4. Installing an IDE (Integrated Development Environment)
Lesson #5: Compiling Your First Program
Chapter 1. C++ Basics
Lesson #10: Variables, Initialization, and Assignment
Lesson #11: cout, cin, and endl
Lesson #13: Function Parameters and Arguments
Lesson #14: Why are functions useful, and how to use them effectively?
Lesson #16: Keywords and Identifiers
Lesson #18: Basic Code Formatting
Lesson #19: Function Prototype and Forward Declaration
Lesson #20: Multi-File Programs
Lesson #22: Preprocessor Directives
Lesson #23: Header guards and #pragma once
Lesson #24. Name conflict and std namespace
Lesson #25: Developing Your First Programs
Lesson #26: Debugging Programs: Stepping and Breakpoints
Lesson #27: Debugging Programs: Call Stack and Variable Tracking
Chapter 2. Variables and Basic Data Types in C++
Lesson #28: Initialization, Assignment, and Declaration of Variables
Lesson #29: The Void Data Type
Lesson #31: Integer Data Types: Short, Int, and Long
Lesson #32: Fixed-Size Integer Data Types
Lesson #33: Floating-Point Data Types: Float, Double, and Long Double
Lesson #34: The Boolean Data Type
Lesson #35: The char Data Type
Lesson #36: Literals and Magic Numbers
Chapter 3. Operators in C++
Lesson #38: Operator Precedence and Associativity Rules
Lesson #39. Arithmetic Operators
Lesson #40: Increment, Decrement, and Side Effects
Lesson #41: The Conditional Ternary Operator, the Sizeof Operator, and the Comma
Lesson #42: Comparison Operators
Lesson #43. Logical Operators: AND, OR, NOT
Lesson #44: Converting numbers from binary to decimal and vice versa
Chapter 4. Scope and Other Variable Types in C++
Lesson #47: Statement Blocks (Compound Statements)
Lesson #48: Local Variables, Scope, and Lifespan
Lesson #50: Why are global variables evil?
Lesson #52: Relationships, Scope, and Variable Lifespan
Lesson #55: Implicit Data Type Conversion
Lesson #56: Explicit Data Type Conversion
Lesson #57. Strings (std::string)
Lesson #60: Type Aliases: Typedef and Type Alias
Chapter 5. Code Execution Order in a Program. Loops and Branching in C++
Lesson #63: Program Flow Control Operators
Lesson #64: Conditional if/else Statements
Lesson #65: The Switch Statement
Lesson #66: The goto Statement
Lesson #70: Break and Continue Statements
Lesson #71: Random Number Generation
Lesson #72: Handling Incorrect User Input
Chapter No. 6. Arrays, Strings, Pointers, and References in C++
Lesson #77: Selection Sorting of Arrays
Lesson #78: Multidimensional Arrays
Lesson #82: Pointers and Arrays
Lesson #83: Address Arithmetic and Array Indexing
Lesson #84: C-Style String Constants
Lesson #85: Dynamic Memory Allocation
Lesson #87: Pointers and const
Lesson #89: References and Const
Lesson #90: Pointer Access Operator
Lesson #93. Pointers to pointers
Lesson #94: Introduction to std::array
Chapter 7. Functions in C++
Lesson #96: Function Parameters and Arguments
Lesson #98: Passing by Reference
Lesson #99. Transfer to an address
Lesson #100: Returning Values by Reference, Address, and Value
Lesson 101: Built-in Functions
Lesson #102: Function Overloading
Lesson #104: Function Pointers
Lesson #107. Recursion and Fibonacci Numbers
Lesson #108: Error Handling, cerr, and exit()
Lesson #109. assert and static_assert
Chapter 8. OOP Basics in C++
Lesson #112: Introduction to OOP
Lesson #113: Classes, Objects, and Methods
Lesson #114: Public and Private Access Specifiers
Lesson #115: Encapsulation, Getters, and Setters
Lesson #117: Class Member Initialization List
Lesson #118: Initializing Non-Static Class Members
Lesson #119: Delegating Constructors
Lesson #121: The Hidden *this Pointer
Lesson #122: Classes and Header Files
Lesson #123: Classes and Const
Lesson #124: Static Class Member Variables
Lesson #125: Static Class Methods
Lesson #126: Friend Functions and Classes
Lesson #127: Anonymous Objects
Lesson #128: Nested Data Types in Classes
Chapter 9. Operator Overloading in C++
Lesson #130: Introduction to Operator Overloading
Lesson #131: Operator Overloading with Friend Functions
Lesson #132: Operator Overloading with Regular Functions
Lesson #133: Overloading Input and Output Operators
Lesson #134: Operator Overloading via Class Methods
Lesson #135: Overloading Unary Operators +, -, and Logical NOT
Lesson #136: Overloading Comparison Operators
Lesson #137: Overloading the Increment and Decrement Operators
Lesson #138: Overloading the Index Operator []
Lesson #139: Operator Overloading ()
Lesson #140: Overloading Data Type Conversion Operators
Lesson #142: Copy Initialization
Lesson #143: Conversion Constructors, Explicit, and Delete Keyword
Lesson #144: Overloading the Assignment Operator
Chapter 10. Introduction to Object Relationships in C++
Lesson #146: Types of Relationships Between Objects
Lesson #147. Object Composition
Lesson #151: Container Classes
Chapter 11. Inheritance in C++
Lesson #153: Introduction to Inheritance
Lesson #154: Basic Inheritance
Lesson #155: The Order of Constructing Child Classes
Lesson #156: Constructors and Initialization of Child Classes
Lesson #157: Inheritance and the protected access specifier
Lesson #158: Adding New Functionality to a Child Class
Lesson #159: Overriding Parent Class Methods
Lesson #160: Hiding Parent Class Methods
Chapter 12. Virtual Functions in C++
Lesson #162: Pointers, References, and Inheritance
Lesson #163: Virtual Functions and Polymorphism
Lesson #164: Override and Final Modifiers
Lesson #165: Virtual Destructors and Virtual Assignment
Lesson #166: Early and Late Binding
Lesson #168: Pure Virtual Functions, Interfaces, and Abstract Classes
Lesson #169. Virtual Basic Classroom
Lesson #171: Dynamic Type Casting. The dynamic_cast Operator
Chapter No. 13. Templates in C++
Lesson #173: Function Templates
Lesson #174: Function Template Instances
Lesson #176: Non-type Parameter in a Template
Lesson #177: Explicit Function Template Specialization
Lesson #178: Explicit Class Template Specialization
Lesson #179: Partial Template Specialization
Chapter 14. Exceptions in C++
Lesson #181. Exceptions. Why are they needed?
Lesson #182: Exception Handling: Throw, Try, and Catch Statements
Lesson #183: Exceptions, Functions, and Stack Unwinding
Lesson #184: Uncaught Exceptions and Catch-All Handlers
Lesson #185: Exception Classes and Inheritance
Lesson #186: Rethrowing Exceptions
Lesson #187: Functional Try Block
Lesson #188: The Disadvantages and Dangers of Using Exceptions
Chapter 15. Smart Pointers and Move Semantics in C++
Lesson #189: Smart Pointers and Move Semantics
Lesson #190: R-Value References
Lesson #191: The Move Constructor and the Move Assignment Operator
Lesson #192. std::move() function
Lesson #193: Smart Pointer std::unique_ptr
Lesson #194: Smart Pointer std::shared_ptr
Chapter 16. The Standard Template Library (STL) in C++
Chapter No. 17. std::string in C++
Lesson #200. The std::string and std::wstring String Classes
Lesson #201: Creating, Destroying, and Converting std::string
Lesson #202: Length and Capacity of std::string
Lesson #203. Accessing std::string Characters. Converting std::strings to C-style Strings
Lesson #204: Assigning and Reordering Values with std::string
Lesson #205: Appending to std::string
Lesson #206: Inserting Characters and Strings into std::string
Chapter 18. Input/Output in C++
Lesson #207: Input and Output Streams
Lesson #208: iStream Class Functionality
Lesson #209: ostream and ios Class Functionality. Output Formatting
Lesson #210: Stream Classes and Strings
Lesson #211: Flow States and User Input Validation
Additional lessons
Compiler Configuration: Compiler Extensions
Compiler Configuration: Warning Levels and Errors
Compiler Configuration: Selecting the C++ Language Standard
Introduction to the std::string_view class in C++
Introduction to Iterators in C++
Algorithms in the C++ Standard Library
Connecting and using libraries in Visual Studio
Exception specifications and the noexcept specifier in C++
std::move_if_noexcept() function in C++
Three-way comparison operator in C++
The finale
*Adapted translation from LearnCpp.com
**Ukrainian translation of aCode / C++ Lessons
Step-by-step game development in C++/MFC
Lesson #1: Introduction to Creating SameGame in C++/MFC
Lesson #2: Architecture and Data Storage in SameGame in C++/MFC
Lesson #3: Drawing SameGame in C++/MFC
Lesson #4: Event Handling in SameGame in C++/MFC
Lesson #5: Working with the SameGame Algorithm in C++/MFC
Lesson #6: Working with the Menu in SameGame in C++/MFC
Lesson #7: Adding Difficulty Levels to SameGame in C++/MFC
Lesson #8: Block Sizes and Numbers in SameGame in C++/MFC
Lesson #9: Putting the finishing touches on SameGame in C++/MFC
Note: Special thanks to Dmitry Bushuev for his help with translation from cprogramming.com.
C++ Practical Exercises
Part 1: C++ Practice Exercises
Part 2: C++ Practice Exercises
Part 3: C++ Practice Exercises
Part 4: C++ Practice Exercises
Part 5: C++ Practice Exercises
Part 6: C++ Practice Exercises
Part 7: C++ Practice Exercises
Part 8: C++ Practice Exercises
Part 9: C++ Practice Exercises
Part 10: C++ Practice Exercises
Part 11: C++ Practice Exercises
Part 12: C++ Practice Exercises
Part 13: C++ Practice Exercises
Part 14: C++ Practice Exercises
Part 15: C++ Practice Exercises
Part 16: C++ Practice Exercises
Part 17: C++ Practice Exercises
Part 18: C++ Practice Exercises
Part 19: C++ Practice Exercises
Part 20: C++ Practice Exercises
Part 21: C++ Practice Exercises
Part 22: C++ Practice Exercises
SFML Graphics Library Tutorials
Explore More IT Terms
A
B
C
D
E
F
H
K
W
- What are databases, and why do they need DBMS and SQL?
- What do Linux distributions consist of?
- What is a GPU in a computer, in simple terms?
- What is Linux? The History of Linux
- What is the OSI Model: A Complete Explanation of the Seven Layers and Their Role in Networking
- Which Linux distribution should you choose? A Linux distribution overview
