Get Started Now

Intro to C++ Programming

Starting from the fundamentals, become a C++ software engineer, step by step.

LATEST UPDATES

Screenshot from Cyberpunk 2077
Module One

Intro to C++ Programming

Starting from the basics, become a C++ software engineer, step by step

Screenshot from Cyberpunk 2077
Screenshot from The Witcher 3: Wild Hunt
Screenshot from Warhammer: Total War
Screenshot from Cyberpunk 2077
Module Two

Professional C++

Comprehensive course covering advanced concepts, and how to use them on large-scale projects

Screenshot from Cyberpunk 2077
Screenshot from The Witcher 3: Wild Hunt
Screenshot from Warhammer: Total War
Screenshot from Cyberpunk 2077
Coming Soon

SDL and C++ Development

Learn C++ and SDL development by recreating classic retro games

Screenshot from Cyberpunk 2077
Screenshot from The Witcher 3: Wild Hunt
Screenshot from Warhammer: Total War
MOST POPULAR

Working with the File System

Create, delete, move, and navigate through directories and files using the std::filesystem library.
Abstract art representing computer programming
Ryan McCombe
Updated
Published

In this lesson, we’ll explore the standard library functionality that helps us work with file systems in a platform-agnostic way.

The file system functionality is available by including <filesystem>

#include <filesystem>

Most of the functions and types we’ll be using are within the std::filesystem namespace, which we’ll alias to fs to keep our code less verbose:

namespace fs = std::filesystem;

File System Paths

A guide to effectively working with file system paths, using the std::filesystem::path type.
Abstract art representing computer programming
Ryan McCombe
Updated
Published

In the previous lessons, we represented our file paths as simple strings, but the standard library provides a dedicated class for this: std::filesystem::path.

This type provides additional utility specific to working with the file system. For brevity, we’ll alias std::filesystem to fs in the code examples in this lesson:

namespace fs = std::filesystem;

Directory Iterators

An introduction to iterating through the file system, using directory_iterator and recursive_directory_iterator.
Abstract art representing computer programming
Ryan McCombe
Updated
Published

A common requirement we’ll have is to understand what files and directories exist in a specific location on the file system.

We can accomplish this using iterators that are provided within the std::filesystem namespace, which we’ll alias to fs in this lesson:

namespace fs = std::filesystem;

File Streams

A detailed guide to reading and writing files in C++ using the standard library’s fstream type
Abstract art representing computer programming
Ryan McCombe
Updated
Published

Working with files typically forms a big part of our C++ projects. We often need to read data from and write data to locations on the user's file system.

To do this, we use file streams. As the name suggests, these are streams, so we'll be leaning heavily on what we learned in our previous chapter. File streams are direct children of istream and ostream, so often we'll be using the exact same methods.

The standard library's implementation of file streams is available within the fstream header:

#include <fstream>

We have three main options for creating file streams:

  • std::ifstream - An input stream, used for reading data from a file. This inherits from std::istream.
  • std::ofstream - An output stream, used for writing data to a file. This inherits from std::ostream.
  • std::fstream - A bidirectional stream, which allows us to both read and write data to the same file. This inherits from std::iostream, which in turn inherits from both std::istream and std::ostream

Replacement Algorithms

An overview of the key C++ standard library algorithms for replacing objects in our containers. We cover replace(), replace_if(), replace_copy(), and replace_copy_if().
Abstract art representing computer programming
Ryan McCombe
Updated
Published

In this lesson, we cover all four of the main C++ standard library algorithms for replacing objects within our containers. The functions we will cover are:

  • replace() searches our range for specific values and replaces those objects with different values.
  • replace_if() searches our range for values that satisfy a predicate and replaces those objects with different values.
  • replace_copy() combines the copy() and replace() algorithms. It copies objects to a new location. If an object matches a specific value, we copy a different object instead.
  • replace_copy_if() combines the copy() and replace_if() algorithms. It copies objects from one location to another. If an object satisfies a predicate function, we copy a different object instead.

All the algorithms in this section are available within the <algorithm> header:

#include <algorithm>

Partition Algorithms

An introduction to partitions, and the C++ standard library algorithms that create them
Abstract art representing computer programming
Ryan McCombe
Updated
Published

A collection is partitioned when similar objects are grouped together based on a rule that separates those objects into two clusters.

For example, the following collection of numbers is partitioned into even and odd numbers. All the even numbers are grouped at the start of the container, while the odd numbers are grouped at the end:

4, -6, 2, 7, 1, 5

Specifically, we can imagine this partition is generated based on the following rule:

[](int x){
  return x % 2 == 0;
}

In our collection, every element for which this function returns true (that is, every even number) occurs before every element for which the function returns false (that is, every odd number)

Set Algorithms

An introduction to set algorithms, and how to implement them using the C++ standard library
Abstract art representing computer programming
Ryan McCombe
Updated
Published

This lesson introduces the 5 main standard library algorithms that are used when working with sets. A set is a collection of objects that does not include any duplicates. For example, the numbers 1, 2, and 3 are a set.

Within maths and computer science writing, a set is often denoted as a comma-separated list surrounded by braces, and we’ll use the same convention here.

For example, the set containing the numbers 1, 2, and 3 would be written {1,2,3}\{1, 2, 3\}

Some additional points are worth noting:

Minimum and Maximum Algorithms

An introduction to the seven minimum and maximum algorithms in the C++ standard library: clamp(), min(), min_element(), max(), max_element(), minmax(), and minmax_element().
Abstract art representing computer programming
Ryan McCombe
Updated
Published

In this lesson, we introduce the minimum and maximum algorithms available within the C++ standard library.

All the algorithms in this section are available within the <algorithm> header:

#include <algorithm>

We will cover clamp(), min(), min_element(), max(), max_element(), minmax(), and minmax_element().

Movement Algorithms

An introduction to the seven movement algorithms in the C++ standard library: move(), move_backward(), rotate(), reverse(), shuffle(), shift_left(), and shift_right().
Abstract art representing computer programming
Ryan McCombe
Updated
Published

In this lesson, we cover the most important movement algorithms. We’ll cover the two main algorithms for moving objects between containers: move() and move_backward().

We’ll also introduce 5 algorithms for moving elements around within their existing container: rotate(), reverse(), shuffle(), shift_left() and shift_right().

All the algorithms in this section are available within the <algorithm> header:

#include <algorithm>

Copying Algorithms

An introduction to the 7 copying algorithms in the C++ standard library: copy(), copy_n(), copy_if(), copy_backward(), reverse_copy(), rotate_copy(), and unique_copy().
Abstract art representing computer programming
Ryan McCombe
Updated
Published

In this lesson, we cover the most essential copying algorithms. We will cover the seven main algorithms for copying objects from one container to another: copy(), copy_backward(), rotate_copy(), reverse_copy(), copy_if(), copy_n() and unique_copy().

All the algorithms in this section are available within the <algorithm> header:

#include <algorithm>

What it means for an object to be copied is defined by the copy semantics of its type. We cover copy semantics in more detail in a separate lesson:

Module One
3D art showing a progammer setting up a development environment

Intro to C++ Programming

Become a software engineer with C++. Starting from the basics, we guide you step by step along the way

Free, unlimited access

This course includes:

  • 56 Lessons
  • Over 200 Quiz Questions
  • 95% Positive Reviews
  • Regularly Updated
  • Help and FAQ
Module Two
A computer programmer

Professional C++

Comprehensive course covering advanced concepts, and how to use them on large-scale projects.

Free, unlimited access

This course includes:

  • 124 Lessons
  • 550+ Code Samples
  • 96% Positive Reviews
  • Regularly Updated
  • Help and FAQ
Coming Soon
sdl2-promo.jpg

Game Dev with SDL2

Learn C++ and SDL development by creating hands on, practical projects inspired by classic retro games

Under Construction
Get Started Now

Intro to C++ Programming

Starting from the fundamentals, become a C++ software engineer, step by step.

Contact|Privacy Policy|Terms of Use
Copyright © 2024 - All Rights Reserved