
Master intermediate to advanced C++ concepts through hands-on coding, exceptions, and file I/O. Explore the standard template library, smart pointers, templates, and C++11 features, ending with a fractal image project.
Where to find the source code you see in the tutorials.
Explore standard C++ exceptions by throwing from a constructor that allocates memory with new, catch the exception by reference, and use the what() method from the standard exception base class.
Create and derive custom exception classes from the C++ standard exception, override what() to describe the error, and verify behavior by throwing and catching the exception in a try-catch block.
Learn how to catch exceptions in the correct order in C++, ensuring subclasses are caught before their parent classes to respect polymorphism, with examples using standard exceptions and derived ones.
Learn advanced C++ programming by reading text files, opening and reading with ifstream, using getline, and handling end-of-file in a practical tutorial.
Learn to read formatted text data from files in C++, using getline with delimiters, extract numbers with the stream operator, and handle whitespace and errors robustly.
Learn how to read and write binary files in C++. Write a non-padded struct to a binary file, and read it back to verify the data.
Learn how to use vectors in C++, an STL template class that acts as a resizable array, supporting indexing, push_back, size, and iterator-based loops with begin and end.
Discover how vectors manage memory in C++, including size vs capacity and how capacity grows, with push_back, reserve, resize, and clear. Compare index-based loops and iterators for efficient iteration.
Explore C++ lists, a doubly linked list with insertions at the beginning or middle and erasing elements. Learn to use iterators, push front, and handle iterator invalidation after erase.
Explore maps in the C++ standard template library, storing unique key-value pairs, inserting and overwriting entries, and using iterators and find to test presence.
Explore using custom objects as map values with a Person class, including default constructors, initialization lists, and the nuances of copy construction and assignment in C++.
Learn how to use custom objects as keys in maps by overloading the less than operator, ensuring const correctness, and comparing name and age to manage keys and values.
Learn how multimaps store duplicate keys in C++, insert pairs, iterate with iterators, and retrieve value ranges with equal_range, highlighting differences from maps.
Explore stacks and queues in C++, comparing last-in, first-out with first-in, first-out. Learn push and pop, top and front access, and risks of invalidated references after pops.
Sort a vector of test objects in c++ with operator< or a comparator. Sort by name and by id using iterators, with friend access and deque usage.
Travel through nested STL data types using vectors and maps to model complex data structures. Learn when to replace nested types with simple classes.
Explore overloading the assignment operator in C++ by implementing operator equals as a method, returning a reference, and understanding shallow versus deep copies, copy constructors, and the rule of three.
Learn how to overload the left bit shift operator to print a test object with id and name using cout, via a friend function returning an upstream stream.
Overload the plus operator for a complex class, using freestanding and member forms to add complex numbers or a double, returning a new complex result.
Overload the dereference operator to implement the complex conjugate, returning a new complex number with the imaginary part sign-flipped, while exploring operator precedence and bracket usage.
Learn that C++ templates require seeing implementation and definition together, so define template classes in header files and avoid dot cpp separation; understand instantiation with types like vector of strings.
Learn how template classes in C++ enable writing generic classes that store and manipulate user-specified types using a type parameter t, with examples like vector, stream insertion, and maps.
Explore template functions and type inference in c++ by comparing template and non-template overloads, using diamond brackets to guide type selection and avoid compilation errors.
Explore function pointers in C++, learn how to declare, assign, and call a function pointer, compare with lambda expressions, and understand their role in virtual tables.
Learn how to use function pointers in C++ to pass criteria tests to algorithms, count matches in a string vector with a custom tester.
Explore object slicing and polymorphism in C++ by comparing non-virtual and virtual methods, showing how upcasting and copy construction can slice subclass data, and how a virtual destructor ensures cleanup.
Learn abstract classes and pure virtual functions in C++, preventing base instantiation while deriving concrete animals like dog from an animal base class; use pointers and polymorphism for unified handling.
Explore decltype and typeid in c++11, enable c++11 in your compiler with flags, include the type info header, and see how typeid exposes type information and name mangling.
Learn how to implement nested template classes in c++ using a ring buffer to support a range-based loop, and expose a compatible iterator for iteration.
Implement a template ring buffer class in a header file using a dynamic array. Add values with a wraparound parse index and return elements by index as references, without iterators.
Learn to make a ring buffer iterable by implementing begin and end, a nested iterator with ++ and * operators, enabling range-based for loops in C++98 and C++11.
Review C++ 98 initialization concepts with curly brackets for arrays and public struct members. Preview C++11 improvements that allow bracket initialization of vectors and anonymous data type syntax.
Discover brace initialization in C++11, including initialization of vectors, arrays, strings, and pointers, the move from C++98, and the new nullptr keyword for pointers.
Learn how to initialize lists in C++11 with initializer lists, apply them in constructors and functions, and iterate braced values like {apple, orange, banana}.
Shows object initialization in C++11 using brace initialization and defaulted constructors via equals default, and explains how to delete copy and assignment to prevent copying.
Learn lambda expressions in c++11, including anonymous functions stored in auto and passed to functions via function pointers, with direct invocation and compiler enablement guidance.
Explore lambda expression parameters and return types in C++, learn to define and invoke lambdas, use function pointers, and apply trailing return type syntax.
Explore the standard function type in C++11, enabling any callable, including lambdas and function pointers, and use it with count_if on a string vector.
Explore the mutable keyword in C++ lambda expressions, learn how to modify a by-value captured variable inside a lambda, and see how copies change without altering the original.
Explore copy elision and return value optimization in C++ to understand how temporary objects are avoided in both C++98 and C++11, and preview move semantics.
Explore memory allocation in a class, including zeroing a buffer with memset or empty braces, move constructors, and copy constructors with memcpy, protecting against memory leaks with delete[].
Learn how rvalue references differentiate temporary and non-temporary values in C++, overload functions for lvalue and rvalue parameters, and boost performance with move semantics.
learn how move constructors in c++11 steal resources from a temporary rvalue, transferring the test object's p_buffer to the target and nulling the source so deletion on null is safe.
Master the move assignment operator in C++ by safely deleting old memory, transferring ownership of buffers, and returning the current object, while exploring move constructors and the rule of three.
Master static_cast in c++, casting between parent and child types and leveraging polymorphism. Recognize risks of unsafe casts and the handling of rvalue and lvalue references in c++11.
Explore reinterpret cast in c++, compare it with dynamic_cast and static_cast, and understand why it performs a binary, low-check cast that can cast anything to anything and is best avoided.
Learn how to use std::bind in c++11 to create bound aliases for functions and methods, using placeholders and the functional header to rearrange or fix arguments.
Learn how shared pointers in C++11 keep an object alive until all pointers go out of scope, contrasting them with unique pointers, and use make_shared for efficient creation.
Create a Mandelbrot fractal image in a hello-world C++11 project, write it to a bitmap file, explore binary bitmap formats and zoom capabilities, and study library creation.
Master the bitmap file and info headers, using 32-bit and 16-bit types with pragma pack, and set width, height, 24-bit color, no compression, zero data size, and 2400 resolution.
Learn to build a self-contained bitmap class in C++ for writing fractal images, with a width/height constructor, setPixel for RGB colors, and a boolean write method.
Configure bitmap file header and info header, compute file size, data offset, width, height, and pixel data to create a bmp image.
Learn to set bitmap pixels using a unique pointer and pointer arithmetic, then color the image by setting blue and green to 0 and red to 255.
Scale bitmap coordinates to minus one to plus one by applying offset and scaling to x fractal and y fractal, then track min and max values.
Implement a Mandelbrot fractal class in C++: static get_iterations and a max_iterations constant. Build a simple main loop to map iterations to color and highlight compilation checks.
Improve the Mandelbrot fractal's appearance by equalizing x and y scaling to prevent squashing, fit the image to the screen, and experiment with color mapping by squaring color values.
Validate the histogram by printing it and inspecting pixel counts per iteration. Also sum all histogram values to verify they equal the total number of pixels (width times height).
Eliminate max iterations from the histogram to prevent skewing the color and ensure we store only iterations less than max iterations, avoiding writes to unallocated memory.
Color the fractal by using a histogram of per-pixel iteration counts to drive a hue-based RGB rendering after tallying total iterations.
Apply color transforms by computing green via pow(hue) in C++ using the math header, and set max-iteration pixels to black, to enhance the fractal bitmap before exploring zoom.
Implement a stub zoom list class in C++, storing zooms in a vector, adding via ADD, and converting bitmap coordinates to fractal coordinates with do_zoom that returns a double pair.
Learn to zoom into a fractal, adjust coordinates and zoom factor, and observe how iteration depth reveals intricate Mandelbrot detail and edge color transitions.
Learn to reorganize the main function by refactoring into a fractal creator class with methods to calculate iterations, draw fractal, and write bitmap, plus an add zoom operation.
Implement the fractal creator class and refactor the code to use member variables for width, height, zoom list, histogram, fractal, and bitmap, then initialize zooms, calculate total iterations, and draw.
Build a simple RGB color class in C++ with double red, green, and blue components, a constructor, and a minus operator, then apply it to fractal color gradients.
Use the RGB class to interpolate colors from a start color to an end color by computing the color difference for red, green, and blue. Move zoom handling to main.
Calculate range totals by counting fractal pixels across iteration ranges in a Mandelbrot render, using a range totals vector, a first-range flag, and a debugging workflow.
Figure out which pixel range corresponds to its iteration count in a Mandelbrot fractal by implementing a get range function, using ranges, asserts, and debugging to prevent out-of-bounds access.
Apply range-based coloring to fractals by mapping range iterations to start and end colors using color differences and histogram data.
Explore advanced c++ fractal programming by tweaking Mandelbrot colors and iterations. Precompute data, optimize with profiling, draw with SDL, enable click-to-redraw and zoom, memory checks with val grind.
This course will take you from a basic knowledge of C++ to using more advanced features of the language. This course is for you if you want to deepen your basic knowledge of C++, you want to learn C++ 11 features, or you've taken my free beginners' C++ course and you're looking for the next step.
We'll start with a look at C++ file handling and move through STL, template classes, operator overloading, lambda expressions, move constructors and much more besides.
At the end of the course I'll show you how to create a program that generates fractal images, using a a few of the language features we've seen in the course and giving you a great work out with smart pointers and arrays.
I'll give you exercises throughout the course, ranging from easy near the start, to quite tricky (but optional!) near the end of the course.