Sign up to track your progress

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

Advanced C++ Programming

Explore advanced C++ topics including memory management, concurrency, performance optimization, and systems programming. Learn modern C++ features and best practices for professional development.

This advanced course covers sophisticated C++ programming techniques used in professional software development. Topics include smart pointers, move semantics, concurrency with threads, template metaprogramming, and performance optimization. You'll also explore systems programming concepts and modern C++ standards (C++17/20/23).

107 lessons 45 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

Managing Memory at Runtime (13 lessons)

Allocate and deallocate memory dynamically on the heap.

Manual Memory Management with new and delete

Allocate single objects on the heap and properly release the memory.

35 minutes

Creating Arrays at Runtime

Allocate arrays on the heap when size is determined at runtime.

20 minutes

Cleaning Up Dynamic Resources

Release heap memory automatically when objects are destroyed.

20 minutes

Multi-Level Indirection

Create 2D arrays on the heap using arrays of pointers.

20 minutes

Generic Pointer Type

Understand void pointers and memory management concepts.

15 minutes

Understanding Function Pointers

Store and invoke functions through pointer variables.

30 minutes

Understanding Stack and Heap Memory

Understand how automatic and dynamic storage differ in allocation and lifetime.

30 minutes

Functions Calling Themselves

Solve problems by having functions call themselves with simpler inputs.

25 minutes

Processing Program Arguments

Accept and parse argc/argv to customize program behavior at launch.

20 minutes

Variable Argument Lists

Understand variadic C functions and why modern alternatives are safer.

20 minutes

Creating Inline Functions

Define inline function objects without declaring a separate named function.

30 minutes

Variable Capture in Lambdas

Learn lambda captures for writing concise, inline functions.

30 minutes

Managing Memory at Runtime Summary

Review and test your understanding of all dynamic memory management concepts covered in this chapter.

20 minutes

References (1 resources)

Additional reference materials for this chapter

Memory Management Terminology

Overview of dynamic memory and runtime memory concepts in this chapter.

Custom Operator Implementations (15 lessons)

Define how operators like +, ==, and << work for your own types.

Customizing Operator Behavior

Enable natural syntax for user-defined types by overloading operators.

20 minutes

Arithmetic Operator Overloading

Implement +, -, *, / as friend functions for symmetric operand access.

25 minutes

Non-Member Operator Overloading

Implement operators as standalone functions using the public interface.

15 minutes

Custom Stream Input/Output

Enable std::cout << and std::cin >> for your custom types.

25 minutes

Member Operator Overloading

Define operators as class members with implicit this pointer access.

20 minutes

Unary Operator Overloading

Implement prefix operators that operate on a single operand.

15 minutes

Comparison Operator Overloading

Implement ==, !=, <, >, <=, >= for type comparisons and sorting.

15 minutes

Increment/Decrement Operator Overloading

Implement both prefix and postfix forms of ++ and -- operators.

20 minutes

Array-Style Access Operator

Enable array-style bracket access for your container types.

15 minutes

Function Call Operator Overloading

Create function objects (functors) callable with the () operator.

15 minutes

Custom Type Conversion Operators

Define implicit and explicit conversions to other types.

20 minutes

Copy Assignment Operator Overloading

Handle object assignment with proper resource management.

20 minutes

Understanding Shallow and Deep Copies

Decide when to copy pointers versus the data they point to.

20 minutes

Combining Operator Overloading with Templates

Write generic operators that work with multiple types.

15 minutes

Custom Operator Implementations Summary

Review and test your understanding of all operator overloading concepts covered in this chapter.

25 minutes

References (1 resources)

Additional reference materials for this chapter

Operator Overloading Terminology

Overview of custom operator implementation concepts in this chapter.

Efficient Resource Management with Move Semantics (8 lessons)

Transfer ownership of resources instead of copying them.

Automatic Memory Management

Use RAII wrappers that automatically manage heap memory lifetime.

25 minutes

Understanding Rvalue References

Understand r-value references and when to use them instead of pointers.

20 minutes

Implementing Move Semantics

Write constructors and assignment operators that steal resources from temporaries.

35 minutes

Casting to Rvalue References

Cast lvalues to rvalues to enable move semantics explicitly.

20 minutes

Exclusive Ownership Smart Pointers

Learn modern memory management with std::unique_ptr.

25 minutes

Shared Ownership Smart Pointers

Learn modern memory management with std::shared_ptr.

20 minutes

Solving Circular References with std::weak_ptr

Learn modern memory management with circular dependency issues with std::shared_ptr, and std::weak_ptr.

25 minutes

Move Semantics Summary

Review and test your understanding of all move semantics and resource management concepts covered in this chapter.

25 minutes

References (1 resources)

Additional reference materials for this chapter

Move Semantics Terminology

Overview of move semantics and resource management concepts in this chapter.

Modeling Relationships Between Objects (8 lessons)

Design how classes relate: composition, aggregation, and association.

Understanding Object Relationships

Distinguish between composition, aggregation, association, and dependency.

15 minutes

Building Complex Objects from Simple Parts

Create objects that own and manage the lifetime of their parts.

30 minutes

Modeling Has-A Relationships

Reference objects that exist independently of the container.

30 minutes

Modeling Uses-A Relationships

Connect objects that collaborate without ownership semantics.

25 minutes

Managing Object Dependencies

Handle temporary usage of objects within function scope.

20 minutes

Creating Custom Container Types

Build classes that store and manage collections of elements.

25 minutes

std::initializer_list

Accept brace-enclosed lists as constructor or function arguments.

25 minutes

Modeling Relationships Between Objects Summary

Review and test your understanding of all object relationship modeling concepts covered in this chapter.

25 minutes

References (1 resources)

Additional reference materials for this chapter

Object Relationships Terminology

Overview of object relationship modeling concepts in this chapter.

Code Reuse Through Inheritance (10 lessons)

Create derived classes that inherit behavior from base classes.

Code Reuse Through Inheritance

Establish is-a relationships between types to share common functionality.

15 minutes

Implementing Class Hierarchies

Learn basic inheritance in C++ to create hierarchical relationships between classes.

25 minutes

Understanding Construction Order

Know when base and derived constructors run during object creation.

20 minutes

Initializing Base and Derived Classes

Pass arguments from derived constructors to base class constructors.

35 minutes

Controlling Inherited Member Access

Learn inheritance and access specifiers to create hierarchical relationships between classes.

30 minutes

Extending Base Class Behavior

Add new member functions and data to derived classes.

20 minutes

Method Overriding in Derived Classes

Redefine base class methods to customize behavior in derived classes.

30 minutes

Shadowing Base Class Members

Hide or modify inherited members to control derived class interface.

25 minutes

Inheriting from Multiple Base Classes

Understand multiple inheritance to create hierarchical relationships between classes.

25 minutes

Code Reuse Through Inheritance Summary

Review and test your understanding of all inheritance and code reuse concepts covered in this chapter.

20 minutes

References (1 resources)

Additional reference materials for this chapter

Inheritance Terminology

Overview of inheritance and code reuse concepts in this chapter.

Runtime Polymorphism with Virtual Functions (12 lessons)

Call derived class methods through base class pointers at runtime.

Base Class Pointers and References

Store derived objects in base class pointers for uniform handling.

30 minutes

Dynamic Dispatch with Virtual Functions

Use the virtual keyword to enable runtime method dispatch.

30 minutes

Ensuring Correct Overrides

Use override to catch errors and final to prevent further overriding.

25 minutes

Virtual Special Member Functions

Ensure proper cleanup in hierarchies with virtual destructors.

20 minutes

Compile-Time vs Runtime Binding

Understand when function calls are resolved at compile-time vs runtime.

25 minutes

How Virtual Functions Work Internally

Understand the virtual table for implementing dynamic behavior in C++.

25 minutes

Defining Abstract Interfaces

Define interfaces with pure virtual functions that derived classes must implement.

30 minutes

Resolving Multiple Inheritance Ambiguity

Avoid diamond inheritance problems with virtual base classes.

20 minutes

Understanding Object Truncation

Understand what happens when derived objects are assigned to base values.

25 minutes

Safe Downcasting with dynamic_cast

Learn dynamic casting and type safety in C++.

25 minutes

Output Streaming for Hierarchies

Implement polymorphic output by combining virtual functions with operator<<.

25 minutes

Runtime Polymorphism with Virtual Functions Summary

Review and test your understanding of all virtual function and polymorphism concepts covered in this chapter.

25 minutes

References (1 resources)

Additional reference materials for this chapter

Polymorphism Terminology

Overview of virtual functions and polymorphism concepts in this chapter.

Generic Programming with Class Templates (7 lessons)

Write type-independent classes instantiated for different types.

Creating Generic Class Types

Define classes that work with any type using template parameters.

25 minutes

Value-Based Template Parameters

Use compile-time constant values as template arguments.

20 minutes

Customizing Template Behavior

Provide custom implementations for specific template argument types.

20 minutes

Specialized Template Implementations

Create entirely different class implementations for specific types.

25 minutes

Partially Specialized Templates

Learn how to write generic, reusable code using partial template specialization.

25 minutes

Pointer Type Specializations

Learn partial template specialization for pointers and understand memory management concepts.

25 minutes

Generic Programming with Class Templates Summary

Review and test your understanding of all class template and generic programming concepts covered in this chapter.

25 minutes

References (1 resources)

Additional reference materials for this chapter

Class Templates Terminology

Overview of generic programming and class template concepts in this chapter.

Error Handling with Exceptions (11 lessons)

Handle runtime errors by throwing and catching exception objects.

Why Exception Handling is Necessary

Learn error handling techniques and why exceptions are needed for robust programs.

25 minutes

Try-Catch Exception Handling

Learn basic exception handling techniques for robust programs.

30 minutes

How Exceptions Propagate

Follow exceptions as they propagate up the call stack.

30 minutes

Handling Unexpected Exceptions

Learn to handle uncaught exceptions and use catch-all handlers for robust programs.

25 minutes

Class-Based Exception Hierarchies

Create exception class hierarchies for organized error handling.

45 minutes

Propagating Exceptions Up the Call Stack

Learn to rethrow exceptions for robust error handling in programs.

25 minutes

Exception Handling in Constructors

Catch exceptions thrown from member initializer lists.

25 minutes

Exception Safety Considerations

Understand exception dangers and downsides for robust error handling.

25 minutes

Documenting Exception Guarantees

Learn exception specifications and noexcept for robust error handling.

35 minutes

Conditional Move Optimization

Move only when guaranteed not to throw, otherwise copy safely.

25 minutes

Error Handling with Exceptions Summary

Review and test your understanding of all exception handling concepts covered in this chapter.

30 minutes

References (1 resources)

Additional reference materials for this chapter

Exceptions Terminology

Overview of exception handling concepts in this chapter.

File and Stream Input/Output (7 lessons)

Read from and write to files and streams using iostream classes.

Understanding C++ I/O Streams

Understand the iostream class hierarchy and stream concepts.

20 minutes

Reading Data with istream

Extract formatted and unformatted data using istream methods.

25 minutes

Writing Data with ostream

Format output with manipulators and ostream methods.

25 minutes

String Streams for In-Memory I/O

Use stringstream to parse and build strings with stream operations.

20 minutes

Handling Stream Errors and Validation

Check stream error flags and recover from failed input operations.

25 minutes

Reading and Writing Files

Open, read, write, and close files with fstream classes.

25 minutes

Random Access File Operations

Seek to specific positions and read/write binary data directly.

25 minutes

References (1 resources)

Additional reference materials for this chapter

I/O Streams Terminology

Overview of file and stream input/output concepts in this chapter.

Threading Fundamentals (6 lessons)

Learn the fundamentals of multithreading in C++ including std::thread, std::jthread, and thread management.

Introduction to Concurrency

Understand concurrency, parallelism, and why multithreading matters in modern C++.

25 minutes

std::thread Basics

Learn how to create and manage threads using std::thread.

30 minutes

Passing Data to Threads

Learn techniques for passing arguments to thread functions safely.

30 minutes

Joining and Detaching Threads

Understand thread lifecycle management with join and detach operations.

30 minutes

Thread IDs and Hardware Concurrency

Learn about thread identification, hardware capabilities, and thread-local storage.

25 minutes

std::jthread (C++20)

Explore the improved thread class with automatic joining and cooperative cancellation.

30 minutes

References (1 resources)

Additional reference materials for this chapter

Threading Terminology

Overview of threading and concurrency concepts used throughout this chapter.