Sign up to track your progress
Create an account to save your progress, complete exercises, and earn achievements.
C++ Programming Fundamentals
Learn the fundamentals of C++ programming language through hands-on lessons, exercises, and quizzes.
This course is designed for complete beginners who want to learn C++ programming. You'll start with the basics and gradually build up to more complex concepts. By the end of this course, you'll have a solid foundation in C++ programming and be ready to tackle more advanced topics.
Support Free C++ Education
Help us keep this platform free for everyone! Your support enables us to create more high-quality lessons, exercises, and interactive content.
Course Curriculum
C++ Basics (18 lessons)
Fundamental concepts of C++ programming including syntax, variables, and basic operations.
Welcome to C++
Discover what C++ is, why it's powerful, and why it's worth learning in today's programming landscape.
15 minutes
Your First Program: Hello World!
Write your first C++ program that displays "Hello, World!" to the console.
20 minutes
Comments
Learn to document your code with comments and understand best practices for code documentation.
20 minutes
Basic C++ Errors
Develop the essential skill of reading and interpreting compiler error messages to debug your code effectively.
20 minutes
Statements
Learn the basic structure of statements and the different types of statements.
15 minutes
If Statements
Learn how to make decisions in your programs using if statements and conditions.
15 minutes
Whitespace and Formatting
Understand how whitespace works and how to format your code for maximum readability and maintainability.
15 minutes
C++ Naming Conventions
Learn C++ keywords and best practices for naming variables and identifiers.
15 minutes
Objects and Variables
Understand what objects and variables are, and learn the common data types in C++.
30 minutes
Variable Assignment and Initialization
Learn the difference between assignment and initialization, and how to work with variable values safely.
25 minutes
Undefined Behavior
Understand the dangers of uninitialized variables and learn to avoid undefined behavior.
15 minutes
Literals and Operators
Learn about fixed values (literals) and basic operators for mathematical calculations.
15 minutes
Expressions
Learn to combine values, variables, and operators to create expressions that produce results.
20 minutes
Iostream: std::cout, std::cin, and std::endl
Learn basic input and output operations using std::cout and std::cin.
30 minutes
Beyond Basic C++ Errors
More examples of errors you may encounter based on the new topics we have covered.
30 minutes
Developing Your First Program
Walk through the complete process of developing a C++ program from planning to implementation.
15 minutes
C++ Basics Summary
Review and test your understanding of all fundamental C++ concepts covered in this chapter.
55 minutes
References (2 resources)
Additional reference materials for this chapter
Essential C++ Terminology
Overview of fundamental C++ concepts and terminology in this chapter.
C++ Error Reference
A comprehensive reference guide for common C++ errors. Use this as a quick lookup when you encounter unfamiliar error messages.
Built-in Data Types in C++ (12 lessons)
Work with integers, floating-point numbers, booleans, and characters.
Fundamental Data Types
Understand how C++ categorizes data types and choose the right type for your variables.
15 minutes
void Data Type
Understand when and why functions use void to indicate no return value or parameters.
15 minutes
Signed Integers
Store positive and negative whole numbers using signed integer types like int and long.
15 minutes
Unsigned Integers
Understand unsigned integers and why signed types are usually preferred.
20 minutes
Fixed-Width Integers
Use portable integer types like int32_t and std::size_t for predictable behavior.
20 minutes
Scientific Notation Fundamentals
Represent very large and very small numbers using scientific notation in C++.
15 minutes
Using Floating-Point Numbers
Work with decimal numbers using float and double, and understand their precision limitations.
20 minutes
Boolean Data Type
Use true/false values to represent conditions and control program logic.
15 minutes
Character Data Type
Store and manipulate individual characters including letters, digits, and special symbols.
20 minutes
static_cast and Type Conversion
Convert between data types safely using static_cast to avoid data loss.
15 minutes
Built-in Data Types in C++ Summary
Review and test your understanding of all built-in data type concepts covered in this chapter.
20 minutes
References (1 resources)
Additional reference materials for this chapter
Data Types Terminology
Overview of data type concepts and terminology in this chapter.
Functions and Files (14 lessons)
Learn to organize your code using functions and multiple files, making your programs more modular and maintainable.
Functions and Files Summary
Review and test your understanding of all function and file concepts covered in this chapter.
30 minutes
References (1 resources)
Additional reference materials for this chapter
Functions and Files Terminology
Overview of function and file concepts you'll learn in this chapter.
Working with Constants and Text (10 lessons)
Define immutable values with const and constexpr, and manipulate text with std::string.
const Variables
Declare variables that cannot be modified after initialization using const.
25 minutes
Literals
Write numeric, string, and character literals with proper suffixes and formatting.
20 minutes
Numeral Systems
Write numbers in binary, octal, and hexadecimal formats for bit manipulation and memory work.
20 minutes
As-If Rule and Compile-Time Optimization
See how the compiler optimizes code while preserving program behavior.
25 minutes
Constant Expressions
Write expressions that the compiler can evaluate at compile time for better performance.
25 minutes
constexpr Variables - Compile-Time Constants
Create variables whose values are computed at compile time for maximum efficiency.
20 minutes
std::string for Text Handling
Store and manipulate text using the std::string class with built-in memory management.
25 minutes
Using std::string_view
Pass string data efficiently without copying using lightweight string views.
20 minutes
Advanced std::string_view Techniques
Avoid common pitfalls with string_view lifetimes and data ownership.
35 minutes
Working with Constants and Text Summary
Review and test your understanding of all constant and text handling concepts covered in this chapter.
20 minutes
References (1 resources)
Additional reference materials for this chapter
Constants and Text Terminology
Overview of constants and text concepts in this chapter.
C++ Operators and Expressions (9 lessons)
Perform calculations and comparisons using arithmetic, relational, and logical operators.
Understanding Operator Precedence Rules
Predict expression results by understanding which operators evaluate first.
30 minutes
Mathematical Operations with Arithmetic Operators
Perform addition, subtraction, multiplication, and division on numeric types.
20 minutes
Modulo and Power Operations
Calculate remainders with the modulo operator and raise numbers to powers.
20 minutes
Increment and Decrement Operators
Use ++ and -- operators and understand why side effects can cause unexpected behavior.
20 minutes
Comma Operator
Evaluate multiple expressions in sequence and understand when the comma operator is useful.
15 minutes
Ternary Conditional Expressions
Write concise conditional expressions using the ternary operator (?:).
25 minutes
Relational Operators
Compare values with <, >, <=, >=, ==, != and handle floating-point precision issues.
30 minutes
Boolean Logic with Logical Operators
Combine conditions using &&, ||, and ! with short-circuit evaluation.
30 minutes
C++ Operators and Expressions Summary
Review and test your understanding of all operator and expression concepts covered in this chapter.
25 minutes
References (1 resources)
Additional reference materials for this chapter
Operators Terminology
Overview of operator concepts and terminology in this chapter.
Program Flow and Decision Making (16 lessons)
Control execution order with conditionals, loops, and branching statements.
Understanding Program Control Flow
Understand how programs execute sequentially and how to alter that flow.
15 minutes
Conditional Execution with If Statements
Execute different code paths based on conditions using if, else if, and else.
15 minutes
Avoiding Common If Statement Pitfalls
Recognize and fix dangling else, assignment vs comparison, and other common mistakes.
20 minutes
Compile-Time Conditionals with constexpr if
Eliminate unused code branches at compile time based on constant conditions.
15 minutes
Multi-Way Branching with Switch Statements
Replace complex if-else chains with cleaner switch statements for multi-way branching.
20 minutes
Advanced Switch Statement Techniques
Control case execution with break, use [[fallthrough]], and declare variables in cases.
15 minutes
Understanding Goto and Why to Avoid It
Understand why goto creates unmaintainable code and when it might be acceptable.
15 minutes
Repetition with While Loops
Repeat code execution with while loops and control when loops should terminate.
20 minutes
Post-Test Loops with Do-While
Execute loop body at least once before checking the continuation condition.
20 minutes
Counter-Controlled Loops with For
Iterate a specific number of times with initialization, condition, and increment in one place.
20 minutes
Early Program Termination Techniques
Terminate programs gracefully using std::exit and understand when to avoid std::abort.
20 minutes
Generating Random Numbers in C++
Generate unpredictable values for games, simulations, and testing scenarios.
25 minutes
High-Quality Random Numbers with Mersenne Twister
Use the Mersenne Twister algorithm for statistically excellent random number generation.
20 minutes
Creating a Global Random Number Generator
Create a reusable random number generator accessible throughout your program.
20 minutes
Program Flow and Decision Making Summary
Review and test your understanding of all program flow and decision making concepts covered in this chapter.
20 minutes
References (1 resources)
Additional reference materials for this chapter
Control Flow Terminology
Overview of control flow concepts and terminology in this chapter.
Variable Scope and Lifetime Management (15 lessons)
Control where variables are accessible and how long they exist in memory.
Organizing Code with Compound Statements
Group multiple statements together with curly braces to create a single logical unit.
15 minutes
Creating Custom Namespaces
Learn how to organize code with user-defined namespaces and the scope resolution operator to avoid naming conflicts.
35 minutes
Understanding Local Variable Scope and Lifetime
Understand when local variables are created, destroyed, and accessible within blocks.
25 minutes
Working with Global Variables
Declare variables accessible from any function and understand their initialization order.
15 minutes
Understanding Variable Shadowing
Recognize when inner scope variables hide outer ones and avoid related bugs.
20 minutes
Limiting Visibility with Internal Linkage
Restrict variables and functions to a single translation unit using static and unnamed namespaces.
20 minutes
Sharing Variables with External Linkage
Share variables across multiple files using extern declarations.
25 minutes
The Problems with Global Mutable State
Recognize the dangers of mutable global state and learn safer alternatives.
30 minutes
Defining Inline Functions and Variables
Define functions and variables in headers that can be included in multiple files.
25 minutes
Sharing Constants with Inline Variables
Define constants in headers that multiple source files can use without linker errors.
20 minutes
Preserving State with Static Local Variables
Create local variables that persist their values between function calls.
25 minutes
Scope, duration, and linkage Summary
Review and test your understanding of all scope, duration, and linkage concepts covered in this chapter.
30 minutes
Namespace Access with Using Declarations
Import names from namespaces selectively or entirely to reduce typing.
30 minutes
Advanced Namespace Techniques
Use unnamed namespaces for file-private definitions and inline namespaces for versioning.
20 minutes
Variable Scope and Lifetime Management Summary
Review and test your understanding of all variable scope and lifetime management concepts covered in this chapter.
25 minutes
References (1 resources)
Additional reference materials for this chapter
Scope and Lifetime Terminology
Overview of scope and lifetime concepts in this chapter.
Object-Oriented Programming Basics (18 lessons)
Bundle data and functions into classes to model real-world concepts in your programs.
Object-Oriented Programming Fundamentals
Understand the core principles of OOP: encapsulation, abstraction, and data hiding.
20 minutes
Defining Classes in C++
Create your first class with member variables and understand class vs struct.
25 minutes
Adding Behavior to Classes
Define functions inside classes that operate on member data using the implicit this pointer.
20 minutes
Immutable Objects and Const Member Functions
Make objects read-only and mark member functions that don't modify state as const.
20 minutes
Controlling Member Access
Hide implementation details with private members and expose safe interfaces with public ones.
25 minutes
Getters and Setters for Class Members
Provide controlled access to private data through getter and setter functions.
20 minutes
Returning References from Member Functions
Return references to internal data safely and understand the dangers of dangling references.
25 minutes
Encapsulation and Information Hiding
Protect class invariants and reduce coupling by hiding implementation from users of your class.
20 minutes
Object Initialization with Constructors
Initialize objects automatically when they are created using constructor functions.
20 minutes
Efficient Member Initialization
Initialize members directly in the member initializer list for efficiency and correctness.
20 minutes
Parameterless and Default-Parameter Constructors
Create objects without arguments using default constructors and optional parameters.
25 minutes
Constructor Delegation for Code Reuse
Avoid code duplication by having one constructor call another.
20 minutes
Understanding Temporary Objects
Recognize when the compiler creates unnamed temporary objects and their lifetime.
25 minutes
Copying Objects with Copy Constructors
Define how objects are duplicated when passed by value or explicitly copied.
20 minutes
Optimizing Object Construction
Understand how compilers optimize away unnecessary copies through copy elision.
20 minutes
Preventing Implicit Conversions
Prevent surprising implicit conversions by marking single-argument constructors explicit.
25 minutes
Compile-Time Class Objects
Create class objects that can be evaluated entirely at compile time.
25 minutes
Object-Oriented Programming Basics Summary
Review and test your understanding of all object-oriented programming concepts covered in this chapter.
25 minutes
References (1 resources)
Additional reference materials for this chapter
OOP Terminology
Overview of object-oriented programming concepts in this chapter.