DMarlon Studio

Basic C++ course

From scratch: everything you need to write your first programs. In DMarlon Studio, C++ powers native desktop apps with FLTK and the console: design the window and the studio generates the C++.

Start
  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