Sign up to track your progress

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

Back to Courses Intermediate

C++ (plus)

Go deeper with type inference, references, enums, structs, and function templates. Covers compile-time evaluation, std::vector, and arrays.

Building on your C++ fundamentals, this intermediate course dives deep into object-oriented programming. You'll learn to design and implement classes, understand inheritance hierarchies, work with polymorphism, and explore advanced C++ features. Perfect for developers ready to write more sophisticated C++ applications.

104 lessons 55 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

Type Systems and Automatic Type Inference (10 lessons)

Let the compiler deduce types and understand how implicit conversions work.

1
Automatic Type Conversions in C++

Understand when the compiler automatically converts between types and potential pitfalls.

20 minutes

2
Numeric Type Promotions

Understand how small integer and floating-point types are widened in expressions.

20 minutes

3
Converting Between Numeric Types

Convert between integer and floating-point types while avoiding data loss.

25 minutes

4
Safe Initialization and Narrowing Conversions

Prevent accidental data loss using brace initialization that rejects narrowing.

20 minutes

5
Mixed-Type Arithmetic Conversions

Predict what type results when mixing different numeric types in an expression.

20 minutes

6
Manual Type Casting Techniques

Convert types explicitly with static_cast and understand why C-style casts are dangerous.

25 minutes

7
Creating Type Aliases for Clarity

Give complex types readable names using typedef and the modern using keyword.

30 minutes

8
Automatic Type Deduction with auto

Let the compiler infer variable types from their initializers with auto.

25 minutes

9
Function Return Type Deduction

Let the compiler deduce function return types from return statements.

20 minutes

10
Type Systems and Automatic Type Inference Summary

Review and test your understanding of all type system and type inference concepts covered in this chapter.

25 minutes

References (1 resources)

Additional reference materials for this chapter

Type Inference Terminology

Overview of type system and inference concepts in this chapter.

References and Memory Addresses (16 lessons)

Access and manipulate data indirectly through references and pointers.

1
Building Complex Types from Simple Ones

Combine fundamental types into references, pointers, arrays, and user-defined types.

20 minutes

2
Understanding Lvalues and Rvalues

Understand value categories (lvalues and rvalues) for efficient resource management in modern C++.

25 minutes

3
Creating References to Objects

Create aliases to existing objects that cannot be reseated to refer elsewhere.

25 minutes

4
Read-Only References with const

Bind references to rvalues and prevent modification of referenced objects.

25 minutes

5
Efficient Parameter Passing by Reference

Avoid copying large objects by passing them by reference to functions.

25 minutes

6
Read-Only Parameter Passing

Pass objects efficiently without allowing the function to modify them.

30 minutes

7
Understanding Memory Addresses and Pointers

Store memory addresses in pointer variables and access data through them.

35 minutes

8
Representing Absent Pointers with nullptr

Represent absent pointers with nullptr and check for validity before dereferencing.

30 minutes

9
Const Correctness with Pointers

Distinguish between pointers to const data and const pointer variables.

20 minutes

10
Parameter Passing with Pointers

Pass pointers to functions when you need optional parameters or C API compatibility.

25 minutes

11
Advanced Pointer Parameter Techniques

Handle null pointer arguments and modify pointer parameters themselves.

20 minutes

12
Returning References and Pointers from Functions

Return references or pointers from functions without copying, while avoiding dangling issues.

30 minutes

13
Parameter Passing Conventions

Design function parameters for input-only, output-only, or bidirectional data flow.

20 minutes

14
Auto Type Deduction with Pointers and References

Understand how auto interacts with pointer, reference, and const qualifiers.

30 minutes

15
Representing Optional Values with std::optional

Safely represent values that may or may not exist without using null pointers.

30 minutes

16
References and Memory Addresses Summary

Review and test your understanding of all reference and memory address concepts covered in this chapter.

30 minutes

References (1 resources)

Additional reference materials for this chapter

References and Pointers Terminology

Overview of reference and memory address concepts in this chapter.

Custom Data Types with Enums and Structs (16 lessons)

Define named constants with enums and group related data with structs.

1
Creating Custom Data Types

Define your own types to better model your problem domain.

25 minutes

2
Defining Enumeration Types

Create named integer constants that improve code readability and type safety.

30 minutes

3
Converting Enumerations to Integers

Convert enumerators to and from integers for storage and arithmetic operations.

25 minutes

4
String Conversion for Enumerations

Convert enumerators to human-readable strings for output and debugging.

20 minutes

5
Custom Input/Output with Operator Overloading

Enable your custom types to work with std::cout and std::cin.

25 minutes

6
Type-Safe Enumerations with enum class

Use enum class for strongly-typed enumerations that prevent implicit conversions.

25 minutes

7
Grouping Data with Structs

Bundle related variables together into a single composite type.

20 minutes

8
Initializing Struct Members

Initialize all struct members at once using brace initialization syntax.

25 minutes

9
Providing Default Member Values

Specify default values for struct members that apply when not explicitly initialized.

20 minutes

10
Struct Parameter and Return Techniques

Pass structs to functions by value or reference and return them from functions.

25 minutes

11
Additional Struct Features and Best Practices

Use nested structs, struct size/alignment, and other advanced struct features.

20 minutes

12
Accessing Members Indirectly

Access struct members through pointers using the arrow operator (->).

20 minutes

13
Generic Types with Class Templates

Create structs and classes that work with any data type using templates.

30 minutes

14
Automatic Template Argument Deduction

Let the compiler deduce template arguments from constructor parameters.

25 minutes

15
Creating Template Type Aliases

Learn how to write generic, reusable code using alias templates.

20 minutes

16
Custom Data Types with Enums and Structs Summary

Review and test your understanding of all enum and struct concepts covered in this chapter.

25 minutes

References (1 resources)

Additional reference materials for this chapter

Enums and Structs Terminology

Overview of enumeration and struct concepts in this chapter.

Advanced Function Techniques and Templates (11 lessons)

Write reusable code with function overloading and generic function templates.

1
Function Overloading

Define multiple functions with the same name but different parameter types.

20 minutes

2
Overload Differentiation

Understand which parameter differences allow function overloading.

20 minutes

3
Overload Resolution

Predict which overload the compiler selects and resolve ambiguity errors.

25 minutes

4
Deleted Functions

Prevent specific function calls by marking overloads as deleted.

15 minutes

5
Default Arguments

Provide optional parameter values that callers can omit.

20 minutes

6
Function Templates

Write a single function that works with any type using template parameters.

20 minutes

7
Template Instantiation

Understand how the compiler generates concrete functions from templates.

20 minutes

8
Multiple Template Types

Create templates with multiple independent type parameters.

20 minutes

9
Non-Type Template Parameters

Parameterize templates with compile-time constant values like integers.

20 minutes

10
Templates in Multiple Files

Organize template definitions in headers for use across translation units.

20 minutes

11
Advanced Function Techniques and Templates Summary

Review and test your understanding of all advanced function and template concepts covered in this chapter.

30 minutes

References (1 resources)

Additional reference materials for this chapter

Function Templates Terminology

Overview of function overloading and template concepts in this chapter.

Compile-Time Function Evaluation (5 lessons)

Move computation from runtime to compile time for better performance.

1
Compile-Time Function Evaluation

Write functions that can be evaluated at compile time when given constant arguments.

20 minutes

2
Advanced constexpr Function Techniques

Use loops, local variables, and other features inside constexpr functions.

25 minutes

3
Immediate Functions with consteval

Force compile-time evaluation with consteval and detect compile-time context.

25 minutes

4
constexpr Function Best Practices

Apply best practices for writing maintainable constexpr code.

25 minutes

5
Compile-Time Function Evaluation Summary

Review and test your understanding of all compile-time function evaluation concepts covered in this chapter.

20 minutes

References (1 resources)

Additional reference materials for this chapter

Constexpr Terminology

Overview of compile-time function evaluation concepts in this chapter.

Advanced Class Concepts and Techniques (11 lessons)

Use static members, friend functions, and other advanced class features.

1
The this Pointer and Method Chaining

Access the current object with this and enable fluent interfaces with method chaining.

25 minutes

2
Organizing Class Definitions

Split class definitions between header and source files for better compilation.

30 minutes

3
Defining Types Within Classes

Define enums, typedefs, and classes inside another class for encapsulation.

20 minutes

4
Resource Cleanup with Destructors

Clean up resources automatically when objects go out of scope.

20 minutes

5
Implementing Generic Class Behavior

Define member functions for class templates both inside and outside the class.

20 minutes

6
Class-Level Data with Static Members

Share data across all instances of a class with static member variables.

25 minutes

7
Class-Level Functions

Define functions that operate on class-level data without an object instance.

20 minutes

8
Granting External Function Access

Grant non-member functions access to private class members.

25 minutes

9
Cross-Class Access with Friend Declarations

Allow one class to access the private members of another class.

20 minutes

10
Overloading Based on Object Value Category

Provide different behavior for lvalue and rvalue objects using & and && qualifiers.

15 minutes

11
Advanced Class Concepts and Techniques Summary

Review and test your understanding of all advanced class concepts covered in this chapter.

20 minutes

References (1 resources)

Additional reference materials for this chapter

Advanced Class Terminology

Overview of advanced class concepts and techniques in this chapter.

Resizable Arrays with std::vector (13 lessons)

Store collections of elements that can grow and shrink dynamically.

1
Storing Collections of Data

Understand container types and when to use arrays versus other collections.

30 minutes

2
Creating Dynamic Arrays with std::vector

Create vectors with various constructors and initialize them with data.

35 minutes

3
Index Type Considerations for std::vector

Handle signed/unsigned mismatches when indexing vectors with size_t.

20 minutes

4
Efficient Vector Parameter Passing

Pass vectors to functions by reference to avoid expensive copies.

20 minutes

5
Returning Vectors Efficiently

Return vectors from functions efficiently using move semantics.

20 minutes

6
Iterating Through Array Elements

Use for and while loops to process each element in an array.

20 minutes

7
Array Iteration Patterns and Solutions

Apply practical patterns to handle signed/unsigned index conversions.

20 minutes

8
Simplified Iteration with Range-Based For

Iterate over container elements cleanly without managing indices.

20 minutes

9
Type-Safe Array Indexing with Enums

Use enum values as descriptive, type-safe array indices.

20 minutes

10
Managing Vector Size and Memory

Understand std::vector resizing and capacity for efficient data storage and manipulation.

20 minutes

11
Using std::vector as a Stack

Use push_back and pop_back for LIFO stack operations.

25 minutes

12
The Specialized bool Vector

Recognize the quirks and limitations of the space-optimized bool specialization.

15 minutes

13
Resizable Arrays with std::vector Summary

Review and test your understanding of all std::vector and resizable array concepts covered in this chapter.

30 minutes

References (1 resources)

Additional reference materials for this chapter

Vector Terminology

Overview of std::vector and resizable array concepts in this chapter.

Fixed-Size Arrays and C-Style Arrays (14 lessons)

Work with compile-time sized arrays and legacy C-style array syntax.

1
Fixed-Size Arrays with std::array

Use the safer, fixed-size array wrapper from the standard library.

20 minutes

2
Working with std::array Size and Indices

Access elements and query size with bounds-checked and unchecked methods.

15 minutes

3
std::array Parameter and Return Techniques

Pass fixed-size arrays to functions using templates or references.

25 minutes

4
Working with std::array of Custom Types

Initialize arrays of objects with nested braces and understand elision rules.

20 minutes

5
Creating Reference Arrays

Store references in containers using std::reference_wrapper.

20 minutes

6
Using Enumerations with std::array

Use enum values to create descriptive, self-documenting array indices.

20 minutes

7
Understanding Legacy C Arrays

Understand built-in array syntax and its limitations compared to std::array.

25 minutes

8
Array-to-Pointer Conversion

Understand how arrays convert to pointers when passed to functions.

35 minutes

9
Navigating Memory with Pointer Arithmetic

Calculate memory addresses and access elements using pointer offsets.

30 minutes

10
Null-Terminated Character Arrays

Work with null-terminated character arrays from C legacy code.

25 minutes

11
String Literals in C++

Use string literals and understand their storage and lifetime.

20 minutes

12
Working with Multi-Dimensional C Arrays

Create and access 2D and 3D arrays using C-style syntax.

25 minutes

13
Fixed Multi-Dimensional Arrays

Create nested std::array types for multi-dimensional fixed-size storage.

30 minutes

14
Fixed-Size Arrays and C-Style Arrays Summary

Review and test your understanding of all fixed-size array and C-style array concepts covered in this chapter.

30 minutes

References (1 resources)

Additional reference materials for this chapter

Arrays Terminology

Overview of fixed-size and C-style array concepts in this chapter.