This is a list of lectures from the C++ for yourself course.
The course is designed to be consumed from top to bottom, so start at the beginning and you will always have enough knowledge for the next video.
That being said, I aim to leave links in the videos so that one could watch them out of order without much hassle.
Enjoy! π
Hello world program dissection
- First keywords
- What brackets mean
- What do different signs mean
- Intro to "scopes"
- Intro to functions
- Intro to includes
Homework
: hello world program
- Write a simple program that prints
Hello World!
- Learn to compile and run simple programs
Variables of fundamental types
- How to create variables of fundamental types
- Naming variables
- Using
const
,constexpr
with variables - References to variables
Sequence and utility containers
- Sequence containers:
std::array
,std::vector
, their usage and some caveats - Pair container:
std::pair
- Strings from STL:
std::string
- Conversion to/from strings:
to_string
,stoi
,stod
,stof
, etc. - Aggregate initialization
Associative containers
std::map
andstd::unordered_map
- Touch up on
std::set
andstd::unordered_set
Homework
: fortune teller program
- Write a program that tells your C++ fortune
- It reads and writes data from and to terminal
- Stores and accesses these data in containers
Random number generation
- What are random numbers
- How to generate them in modern C++
- Why not to use
rand()
Homework
: the guessing game
- A program that generates a number
- The user guesses this number
- The program tells the user if they are above or below with their guess (or if they've won)
Compilation flags and debugging
- Useful compilation flags
- Debugging a program with:
- Print statements
lldb
debugger
Functions
- What is a function
- Declaration and definition
- Passing by reference
- Overloading
- Using default arguments
Libraries and header files
- Different types of libraries
- Header-only
- Static
- Dynamic
- What is linking
- When to use the keyword
inline
- Some common best practices
Build systems introduction
- Intro to build systems
- Build commands as a script
- Build commands in a
Makefile
CMake introduction
- Build process with CMake
- CMake Variables
- Targets and their properties
- Example CMake project
Using GoogleTest framework for testing code
- Explain what testing is for
- Explain what testing is
- Show how to download and setup googletest
- Show how to write a simple test
Homework
: string processing library
- You will write library that allows to split and trim strings
- You will learn how to:
- Write a CMake project from scratch
- Write your own libraries
- Test them with googletest
- Link them to binaries
Simple custom types with classes and structs
- Explain why the classes are needed
- Implement an example game about a car
- Define classes and structs more formally
Raw pointers
- The pointer type
- Pointers = variables of pointer types
- How to get the data?
- Initialization and assignment
- Using const with pointers
- Non-const pointer to const data
- Constant pointer to non-const data
- Constant pointer to constant data
Object lifecycle
- Creating a new object
- What happens when an object dies
- Full class lifecycle explained
Move semantics
- Why we care about move semantics
- Letβs re-design move semantics from scratch
- How is it actually designed and called in Modern C++?
Constructors, operators, destructor - rule of all or nothing
- βGood styleβ as our guide
- What is βgood styleβ
- Setting up the example
- Rule 1: destructor
- Rule 2: copy constructor
- Rule 3: copy assignment operator
- Rule 4: move constructor
- Rule 5: move assignment operator
- Now we (mostly) follow best practices
- Rule of 5 (and 3)
- The rule of βall or nothingβ
Const correctness
- What is const correctness
- Some rules and examples to follow in order to work with
const
correctly
Homework
: pixelate images in terminal
- You will write a library that allows to pixelate an image
- You will learn how to:
- Work with classes
- Use external libraries
- Read images from disk using
stb_image.h
- Draw stuff in the terminal using
FTXUI
library
- Read images from disk using
- Manage memory allocated elsewhere correctly
- Writing multiple libraries and binaries and linking them together
- Manage a larger CMake project
Keyword static
outside of classes
- Why we should not use
static
outside of classes - Relation to storage duration
- Relation to linkage
- Why we should use
inline
instead
Keyword static
inside classes
- Using
static
class methods - Using
static
class data - What is
static
in classes useful for?
Templates: why would we want to use them?
- Templates provide abstraction and separation of concerns
- Function templates
- Class and struct templates
- Generic algorithms and design patterns
- Zero runtime cost (almost)
- Compile-time meta-programming
- Summary
Templates: what do they do under the hood?
- Compilation process recap
- Compiler uses templates to generate code
- Hands-on example
- Compiler is lazy
How to write function templates
- The basics of writing a function template
- Explicit template parameters
- Implicit template parameters
- Using both explicit and implicit template parameters at the same time
- Function overloading and templates
- Full function template specialization and why function overloading is better
How to write class templates
- How to use templates with classes in C++
- Class method templates
- Class templates
- Class template argument deduction (min. C++17)
- Class template specialization: implicit and explicit
- Full explicit template specialization
- How to fully specialize class templates
- Make sure a specialization follows the expected interface
- Historical reference for
std::vector<bool>
- Specialize just one method of a class
- Specialize method templates of class templates
- Type traits and how to implement them using template specialization
- More generic traits using partial specialization
- Difference between partial and full specializations
- Partial template specialization with more types
- Summary
Forwarding references
Header and source files for templated code
Almost everything about inheritance
- Inheritance enables dependency inversion
- The idea behind dependency inversion
- Similarity to static polymorphism with templates
- How inheritance looks in C++
- Implementation inheritance
- Using
virtual
for interface inheritance and proper polymorphism - How interface inheritance works
- Runtime and memory overhead of using virtual
- Things to know about classes with
virtual
methods - Downcasting using the
dynamic_cast
- Don't mix implementation and interface inheritance
- Implement pure interfaces
- Keyword
final
- Simple polymorphic class example following best practices
- Multiple inheritance
- Detailed
Image
example following best practices
Memory management and smart pointers
- Memory management and smart pointers
- Memory management in C++
- Memory allocation under the hood
- Typical pitfalls with data allocated on the heap
- RAII for memory safety
- Summary
Lambdas in modern C++
- Lambdas
- Overview
- What is a "callable"
- A function pointer is sometimes enough
- Before lambdas we had function objects (or functors)
- How to implement generic algorithms like
std::sort
- Enter lambdas
- Lambda syntax
- When to use lambdas
- Summary
If you do find an error in some of those, please open an issue in this repo!