Sign up to track your progress

Create an account to save your progress, complete exercises, and earn achievements.

C++ Programming Fundamentals

Start from scratch with variables, data types, and functions. Build up to operators, control flow, scope management, and your first classes.

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.

121 lessons 50 hours

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.

Become a Patron

Course Curriculum

C++ Basics (18 lessons)

Fundamental concepts of C++ programming including syntax, variables, and basic operations.

1
Welcome to C++

Discover what C++ is, why it's powerful, and why it's worth learning in today's programming landscape.

15 minutes

2
Your First Program: Hello World!

Write your first C++ program that displays "Hello, World!" to the console.

20 minutes

3
Comments

Learn to document your code with comments and understand best practices for code documentation.

20 minutes

4
Basic C++ Errors

Develop the essential skill of reading and interpreting compiler error messages to debug your code effectively.

20 minutes

5
Statements

Learn the basic structure of statements and the different types of statements.

15 minutes

6
If Statements

Learn how to make decisions in your programs using if statements and conditions.

15 minutes

7
Whitespace and Formatting

Understand how whitespace works and how to format your code for maximum readability and maintainability.

15 minutes

8
C++ Naming Conventions

Learn C++ keywords and best practices for naming variables and identifiers.

15 minutes

9
Objects and Variables

Understand what objects and variables are, and learn the common data types in C++.

30 minutes

10
Data Types

Brief introduction to data types what they are and how they work.

15 minutes

11
Variable Assignment and Initialization

Learn the difference between assignment and initialization, and how to work with variable values safely.

25 minutes

12
Undefined Behavior

Understand the dangers of uninitialized variables and learn to avoid undefined behavior.

15 minutes

13
Literals and Operators

Learn about fixed values (literals) and basic operators for mathematical calculations.

15 minutes

14
Expressions

Learn to combine values, variables, and operators to create expressions that produce results.

20 minutes

15
Iostream: std::cout, std::cin, and std::endl

Learn basic input and output operations using std::cout and std::cin.

30 minutes

16
Beyond Basic C++ Errors

More examples of errors you may encounter based on the new topics we have covered.

30 minutes

17
Developing Your First Program

Walk through the complete process of developing a C++ program from planning to implementation.

15 minutes

18
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.

1
Fundamental Data Types

Understand how C++ categorizes data types and choose the right type for your variables.

15 minutes

2
void Data Type

Understand when and why functions use void to indicate no return value or parameters.

15 minutes

3
sizeof Operator

Determine how many bytes a type or object occupies in memory.

15 minutes

4
Signed Integers

Store positive and negative whole numbers using signed integer types like int and long.

15 minutes

5
Unsigned Integers

Understand unsigned integers and why signed types are usually preferred.

20 minutes

6
Fixed-Width Integers

Use portable integer types like int32_t and std::size_t for predictable behavior.

20 minutes

7
Scientific Notation Fundamentals

Represent very large and very small numbers using scientific notation in C++.

15 minutes

8
Using Floating-Point Numbers

Work with decimal numbers using float and double, and understand their precision limitations.

20 minutes

9
Boolean Data Type

Use true/false values to represent conditions and control program logic.

15 minutes

10
Character Data Type

Store and manipulate individual characters including letters, digits, and special symbols.

20 minutes

11
static_cast and Type Conversion

Convert between data types safely using static_cast to avoid data loss.

15 minutes

12
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.

1
Function Basics

Learn the basics of creating and calling functions in C++.

15 minutes

2
Void Functions

Learn about functions that perform actions without returning values.

15 minutes

3
Functions with Return

Understand how functions can return values to the caller.

25 minutes

4
Parameters and Arguments

Learn to pass data to functions through parameters.

15 minutes

5
Local Scope

Understand variable scope within functions and blocks.

20 minutes

6
Better Programs with Functions

Learn when and why to use functions in your programs.

20 minutes

7
Forward Declarations

Understand function declarations and definitions.

30 minutes

8
Multi-File Programs

Learn to organize code across multiple source files.

20 minutes

9
Namespaces

Prevent naming conflicts using namespaces.

30 minutes

10
The Preprocessor

Understand preprocessor directives and their uses.

20 minutes

11
Header Files

Learn to create and use header files effectively.

25 minutes

12
Header Guards

Prevent multiple inclusion problems with header guards.

25 minutes

13
Program Design with Functions

Learn systematic approaches to program design.

15 minutes

14
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.

1
const Variables

Declare variables that cannot be modified after initialization using const.

25 minutes

2
Literals

Write numeric, string, and character literals with proper suffixes and formatting.

20 minutes

3
Numeral Systems

Write numbers in binary, octal, and hexadecimal formats for bit manipulation and memory work.

20 minutes

4
As-If Rule and Compile-Time Optimization

See how the compiler optimizes code while preserving program behavior.

25 minutes

5
Constant Expressions

Write expressions that the compiler can evaluate at compile time for better performance.

25 minutes

6
constexpr Variables - Compile-Time Constants

Create variables whose values are computed at compile time for maximum efficiency.

20 minutes

7
std::string for Text Handling

Store and manipulate text using the std::string class with built-in memory management.

25 minutes

8
Using std::string_view

Pass string data efficiently without copying using lightweight string views.

20 minutes

9
Advanced std::string_view Techniques

Avoid common pitfalls with string_view lifetimes and data ownership.

35 minutes

10
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.

1
Understanding Operator Precedence Rules

Predict expression results by understanding which operators evaluate first.

30 minutes

2
Mathematical Operations with Arithmetic Operators

Perform addition, subtraction, multiplication, and division on numeric types.

20 minutes

3
Modulo and Power Operations

Calculate remainders with the modulo operator and raise numbers to powers.

20 minutes

4
Increment and Decrement Operators

Use ++ and -- operators and understand why side effects can cause unexpected behavior.

20 minutes

5
Comma Operator

Evaluate multiple expressions in sequence and understand when the comma operator is useful.

15 minutes

6
Ternary Conditional Expressions

Write concise conditional expressions using the ternary operator (?:).

25 minutes

7
Relational Operators

Compare values with <, >, <=, >=, ==, != and handle floating-point precision issues.

30 minutes

8
Boolean Logic with Logical Operators

Combine conditions using &&, ||, and ! with short-circuit evaluation.

30 minutes

9
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.

1
Understanding Program Control Flow

Understand how programs execute sequentially and how to alter that flow.

15 minutes

2
Conditional Execution with If Statements

Execute different code paths based on conditions using if, else if, and else.

15 minutes

3
Avoiding Common If Statement Pitfalls

Recognize and fix dangling else, assignment vs comparison, and other common mistakes.

20 minutes

4
Compile-Time Conditionals with constexpr if

Eliminate unused code branches at compile time based on constant conditions.

15 minutes

5
Multi-Way Branching with Switch Statements

Replace complex if-else chains with cleaner switch statements for multi-way branching.

20 minutes

6
Advanced Switch Statement Techniques

Control case execution with break, use [[fallthrough]], and declare variables in cases.

15 minutes

7
Understanding Goto and Why to Avoid It

Understand why goto creates unmaintainable code and when it might be acceptable.

15 minutes

8
Repetition with While Loops

Repeat code execution with while loops and control when loops should terminate.

20 minutes

9
Post-Test Loops with Do-While

Execute loop body at least once before checking the continuation condition.

20 minutes

10
Counter-Controlled Loops with For

Iterate a specific number of times with initialization, condition, and increment in one place.

20 minutes

11
Controlling Loop Execution

Exit loops early with break or skip iterations with continue.

25 minutes

12
Early Program Termination Techniques

Terminate programs gracefully using std::exit and understand when to avoid std::abort.

20 minutes

13
Generating Random Numbers in C++

Generate unpredictable values for games, simulations, and testing scenarios.

25 minutes

14
High-Quality Random Numbers with Mersenne Twister

Use the Mersenne Twister algorithm for statistically excellent random number generation.

20 minutes

15
Creating a Global Random Number Generator

Create a reusable random number generator accessible throughout your program.

20 minutes

16
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.

1
Organizing Code with Compound Statements

Group multiple statements together with curly braces to create a single logical unit.

15 minutes

2
Creating Custom Namespaces

Learn how to organize code with user-defined namespaces and the scope resolution operator to avoid naming conflicts.

35 minutes

3
Understanding Local Variable Scope and Lifetime

Understand when local variables are created, destroyed, and accessible within blocks.

25 minutes

4
Working with Global Variables

Declare variables accessible from any function and understand their initialization order.

15 minutes

5
Understanding Variable Shadowing

Recognize when inner scope variables hide outer ones and avoid related bugs.

20 minutes

6
Limiting Visibility with Internal Linkage

Restrict variables and functions to a single translation unit using static and unnamed namespaces.

20 minutes

7
Sharing Variables with External Linkage

Share variables across multiple files using extern declarations.

25 minutes

8
The Problems with Global Mutable State

Recognize the dangers of mutable global state and learn safer alternatives.

30 minutes

9
Defining Inline Functions and Variables

Define functions and variables in headers that can be included in multiple files.

25 minutes

10
Sharing Constants with Inline Variables

Define constants in headers that multiple source files can use without linker errors.

20 minutes

11
Preserving State with Static Local Variables

Create local variables that persist their values between function calls.

25 minutes

12
Scope, duration, and linkage Summary

Review and test your understanding of all scope, duration, and linkage concepts covered in this chapter.

30 minutes

13
Namespace Access with Using Declarations

Import names from namespaces selectively or entirely to reduce typing.

30 minutes

14
Advanced Namespace Techniques

Use unnamed namespaces for file-private definitions and inline namespaces for versioning.

20 minutes

15
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.

1
Object-Oriented Programming Fundamentals

Understand the core principles of OOP: encapsulation, abstraction, and data hiding.

20 minutes

2
Defining Classes in C++

Create your first class with member variables and understand class vs struct.

25 minutes

3
Adding Behavior to Classes

Define functions inside classes that operate on member data using the implicit this pointer.

20 minutes

4
Immutable Objects and Const Member Functions

Make objects read-only and mark member functions that don't modify state as const.

20 minutes

5
Controlling Member Access

Hide implementation details with private members and expose safe interfaces with public ones.

25 minutes

6
Getters and Setters for Class Members

Provide controlled access to private data through getter and setter functions.

20 minutes

7
Returning References from Member Functions

Return references to internal data safely and understand the dangers of dangling references.

25 minutes

8
Encapsulation and Information Hiding

Protect class invariants and reduce coupling by hiding implementation from users of your class.

20 minutes

9
Object Initialization with Constructors

Initialize objects automatically when they are created using constructor functions.

20 minutes

10
Efficient Member Initialization

Initialize members directly in the member initializer list for efficiency and correctness.

20 minutes

11
Parameterless and Default-Parameter Constructors

Create objects without arguments using default constructors and optional parameters.

25 minutes

12
Constructor Delegation for Code Reuse

Avoid code duplication by having one constructor call another.

20 minutes

13
Understanding Temporary Objects

Recognize when the compiler creates unnamed temporary objects and their lifetime.

25 minutes

14
Copying Objects with Copy Constructors

Define how objects are duplicated when passed by value or explicitly copied.

20 minutes

15
Optimizing Object Construction

Understand how compilers optimize away unnecessary copies through copy elision.

20 minutes

16
Preventing Implicit Conversions

Prevent surprising implicit conversions by marking single-argument constructors explicit.

25 minutes

17
Compile-Time Class Objects

Create class objects that can be evaluated entirely at compile time.

25 minutes

18
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.