
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 the basics of c++ exceptions, using try, throw, and catch blocks; handle int and string errors and propagate through nested function calls.
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.
Explore struct packing and padding in C++, compare string against a fixed-size char array, and disable padding with pragma pack(push, 1) to write non-padded structs to binary files.
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 two-dimensional vectors in C++, modeling a grid with a vector of vectors. Initialize and access with grid[row][col], iterate by rows then columns, print the grid, and understand ragged arrays.
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.
Learn the C++ set STL class: it stores unique, ordered elements, supports insert, find, and count, and enables using custom objects via the less-than operator.
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.
Implement a custom complex number class in c++ with real and imaginary parts, including constructors, copy and assignment operators, and overloading the stream insertion operator.
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.
Learn to overload the equals and not equals operators for a complex class by comparing real and imaginary parts, implementing the operators in header and cpp, and testing with examples.
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 in C++, learn how to create generic functions that work with any type, and see how they mix with template classes, type inference, and function overloading.
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 C++ functors, a way to pass blocks of code to functions using operator() overloads. Build stateful predicate objects for flexible tests, alongside function pointers and lambdas.
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 the auto keyword in c++11 lets auto figure out a variable's type from its initializer, simplifying declarations and enabling auto in function return types and templates.
Learn the enhanced for loop in C++11 and use auto to iterate arrays, vectors, and strings, showcasing a time-saving, simpler syntax for iteration.
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 lambda capture expressions in C++, learn to capture local variables by value or by reference, use default captures with = or &, and specify exceptions.
Explore capturing this in lambda expressions in C++11 by capturing local variables and instance variables by reference. Learn how by value vs by reference and where to place captures.
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.
Master delegating constructors in c++11 by calling one constructor from another, contrast with c++98, and apply constructor initialization lists and equals default with safe, common initialization.
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[].
Explore the distinction between lvalues and rvalues in c++, and see how addresses, pointers, and temporaries shape expressions, including function return values and move constructors.
Explore l value references in c++ 98, how they bind to l values, why they can’t bind to rvalues, and how const and mutable bindings affect temporaries.
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.
Explore unique pointers in C++11, showing automatic memory management from allocation to destruction, including single objects and arrays, and note auto pointer deprecation.
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.
Explore cross-platform GUI options for C++ development, from Windows API to widgets, GTK+, and Q Studio, and learn to balance native look and feel, licensing, and compilation considerations.
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.
Learn to build a bitmap file header in C++ by defining a packed struct with a BM signature and a 32-bit size field, using include guards.
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.
Allocate bitmap memory with a unique pointer for pixel data and write to a file. Use width, height, and three color channels per pixel, with automatic cleanup.
Configure bitmap file header and info header, compute file size, data offset, width, height, and pixel data to create a bmp image.
Write a bitmap to a binary file using an off stream, including the bitmap header, info header, and 800 by 600 pixel data at three bytes per pixel.
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.
Explore implementing the Mandelbrot fractal algorithm in C++ using complex numbers, iterating Z = Z*Z + C with a max iteration limit, and mapping results to bitmap colors.
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.
Use histogram coloring by building an iteration-count histogram and applying it to color the fractal image in a Mandelbrot C++ implementation.
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.
Store the per-pixel iteration counts in memory using an index of y times width plus x, enabling later use with the fractal image and histogram, via a unique_ptr.
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.
Explore a manual zoom workflow for fractal images, using color-based brightness to reveal detail, by selecting a point, centering it, and applying repeated zooms with a simple zoom class.
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.
Apply the next step of the fractal zoom algorithm by converting bitmap coordinates to fractal coordinates, centering the view on a clicked point, and updating the combined scale from 1.
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.
Learn to define color ranges for fractal rendering by mapping iteration ranges to start and end colors, using vectors and a range concept to create smooth transitions.
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.