Your own types and the standard library
Defining structs and classes, then using the containers and algorithms that make up the heart of everyday C++.
About 13 hours of study
Learning objectives
- Define structs and simple classes
- Use map and set
- Choose a container for the order you need
- Apply iterators and standard algorithms
Lessons
- 1
Structs and your first class
Group related data with struct, then protect it in a class with private members, a constructor and methods.
- 2
Maps and sets
Look values up by key with map, keep unique sorted values with set, and choose between ordered and unordered containers.
- 3
Stacks, queues and pairs
Choose the right container for the order you need: stack, queue, deque, priority_queue, and pair for two values together.
- 4
Iterators and algorithms Intermediate
Walk containers with iterators, and use the standard algorithms to sort, search, count and transform instead of writing loops by hand.
Module practice
- C++: A struct with a functionEasy
- C++: A class with rulesMedium
- C++: A stack classHard
- C++: Different valuesEasy
- C++: Count the wordsMedium
- C++: Group the anagramsHard
- C++: Reverse with a stackEasy
- C++: Taking turnsMedium
- C++: The k largestHard
- C++: Largest firstEasy
- C++: Passing marksMedium
- C++: Clean up and searchHard