DMarlon Studio

C++ course

Performance with abstractions: classes, templates and the standard library for big, fast programs.

In DMarlon Studio, C++ powers native desktop apps with FLTK and the console: design the window and the studio generates the C++.

From scratch: everything you need to write your first programs.

  1. 1Hello, worldWrite your first C++ program: the main() function, std::cout and the << operator to show text and numbers in the console.Lesson 1
  2. 2Variables, types and autoDeclare C++ variables with int, double, char, bool and std::string, protect values with const and let auto work out the type.Lesson 2
  3. 3Arithmetic and maths functionsDo maths in C++: integer division and remainder, static_cast, compound operators and the <cmath> functions such as sqrt, pow and round.Lesson 3
  4. 4Text stringsWork with std::string in C++: join with +, measure with size(), cut with substr, search with find and convert between text and numbers.Lesson 4
  5. 5Reading from the keyboardAsk the user for data in C++ with std::cin and >> for numbers and words, and with std::getline for whole lines with spaces.Lesson 5
  6. 6if, else and switchMake decisions in C++ with if, else if and else, choose between fixed cases with switch and break, and use the ternary operator ?:.Lesson 6
  7. 7Comparisons and logicCompare values in C++ with ==, !=, < and >, combine conditions with &&, || and !, and print bools as true and false with std::boolalpha.Lesson 7
  8. 8while and do-whileRepeat code in C++ with while as long as a condition holds, with do-while at least once, and steer the loop with break and continue.Lesson 8
  9. 9for and range-based forCount with the classic C++ for loop, go through collections with the range-based for, and nest loops to build a table.Lesson 9
  10. 10VectorsStore lists in C++ with std::vector: create them, read with [] and at(), get their size with size() and add elements with push_back.Lesson 10
  11. 11Working with vectorsChange a std::vector in C++ with insert, erase and pop_back, then sort it and find its smallest and largest values with <algorithm>.Lesson 11
  12. 12FunctionsWrite C++ functions with a return type and parameters, use void and return, and reuse them to convert temperatures.Lesson 12
  13. 13References and const referencesSee the difference between passing by value and by reference (&) in C++, and use const & to pass vectors and strings without copying them.Lesson 13
  14. 14Default arguments and overloadingGive C++ parameters default values and write several functions with the same name (overloading) that the compiler picks by their arguments.Lesson 14
  15. 15MapsStore key-value pairs in C++ with std::map: a greengrocer's stock with [], count(), erase() and a walk through the keys in order.Lesson 15
  16. 16Pairs and structured bindingsGroup two values with std::pair in C++, return them together from a function and unpack them with C++17 structured bindings.Lesson 16
  17. 17Formatting outputLine up columns and control decimals in C++ with setw, left, right, setfill, fixed and setprecision from <iomanip>: a café menu.Lesson 17
  18. 18Exceptions: try, catch and throwHandle errors in C++ with exceptions: throw std::invalid_argument and std::runtime_error, then catch them with try and catch.Lesson 18
  19. 19Writing and reading text filesSave data to a text file with std::ofstream and read it back with std::ifstream in C++, in the program's current folder.Lesson 19
  20. 20Project: a shopping cartCombine map, functions, references, exceptions, input and iomanip in C++ to build a shopping cart that prints its receipt.Lesson 20

For those who know the basics: the techniques used in real projects.

  1. 1Classes and const methodsWrite your own C++ classes: members, a constructor and const methods, with a bank account that takes deposits and withdrawals.Lesson 1
  2. 2Encapsulation and initializer listsProtect a C++ class's data with private members and getters, and build its members with an initializer list: a thermostat that stays in range.Lesson 2
  3. 3Inheritance and virtual functionsInherit from a C++ class and replace its methods with virtual and override, and see object slicing in action, with a staff payroll.Lesson 3
  4. 4Abstract classes and polymorphismDefine an interface with pure virtual functions in C++ and handle different objects through base pointers: payment methods and their fees.Lesson 4
  5. 5Operator overloadingGive your C++ classes their own operators (+, *, +=, ==, < and <<) with a Money type that stores cents, so sums never lose a penny.Lesson 5
  6. 6RAII and destructorsRelease resources without forgetting with RAII and destructors in C++: a connection that closes itself and a transaction that rolls back on errors.Lesson 6
  7. 7unique_ptr and shared_ptrUse C++ smart pointers, unique_ptr and shared_ptr, so memory frees itself: songs with a single owner or shared by several playlists.Lesson 7
  8. 8Copy and moveTell copying from moving in C++: the rule of five, std::move and noexcept, with an image class that manages its own memory.Lesson 8
  9. 9Function templatesWrite one C++ function for many types with templates: the largest of a list of numbers, words or versions, plus a generic clamp.Lesson 9
  10. 10Class templatesBuild a generic ring buffer with a C++ class template, with the type and the size as parameters: sensor readings and recently opened files.Lesson 10
  11. 11Lambdas and capturesWrite functions on the spot with C++ lambdas: sort tasks, capture variables by value or by reference, and use mutable and auto parameters.Lesson 11
  12. 12STL algorithmsProcess data in C++ with transform, accumulate, count_if, find_if and remove_if with erase: a shop's sales without writing loops.Lesson 12
  13. 13IteratorsWalk through C++ containers with iterators: begin, end, rbegin, next, distance and erase on a std::list, with a route and a playlist.Lesson 13
  14. 14set, unordered_map and dequeChoose the right C++ container: std::set for unique sorted values, std::unordered_map to count page visits and std::deque for a print queue.Lesson 14
  15. 15optional, variant and visitModel values that may be missing with std::optional, and values of several types with std::variant and std::visit, in C++17: ports and cells.Lesson 15
  16. 16Namespaces and enum classOrganise C++ code with namespaces, aliases and using, and use enum class for safe named states: the steps of an online order.Lesson 16
  17. 17Custom exception hierarchiesCreate your own C++ exceptions by deriving from std::runtime_error, with extra data, and catch them from the most specific to the most general.Lesson 17
  18. 18std::function and callbacksBuild an event system in C++ with std::function: register lambdas, functions and methods as callbacks and call them when each event fires.Lesson 18
  19. 19constexpr and static_assertCompute at compile time with constexpr, check conditions with static_assert and pick code with if constexpr: sizes, ratios and tables in C++.Lesson 19
  20. 20Project: shape editorFinal project of the advanced C++ course: a shape editor with classes, polymorphism, unique_ptr and STL algorithms, ready for F9 in DMarlon Studio.Lesson 20