๐ŸŒ C++ Programming ยท subject

C++ Programming Advanced Topics Syllabus

Every chapter and topic of Advanced Topics examined in C++ Programming โ€” 5 chapters, 17 topics, plus 62 flashcards written against it.

5Chapters
17Topics
0Sub-topics
~15hEst. first pass
26%Of C++ Programming
62Flashcards

Advanced Topics syllabus โ€” full chapter and topic list

Expand any chapter to see its topics and sub-topics. This is the whole examinable outline for Advanced Topics in C++ Programming, not a summary of it.

  1. Templates

    3 topics
    • Function Templates
    • Class Templates
    • Template Specialization
  2. Exception Handling

    3 topics
    • Try, Catch, and Throw
    • Standard Exceptions
    • User-defined Exceptions
  3. Standard Template Library (STL)

    4 topics
    • Containers
    • Iterators
    • Algorithms
    • Function Objects
  4. File Handling

    4 topics
    • File Streams
    • Reading from Files
    • Writing to Files
    • Binary Files
  5. Multithreading

    3 topics
    • Thread Management
    • Mutex and Lock
    • Thread Communication

Advanced Topics flashcards for C++ Programming

24 of 62 cards from the Advanced Topics deck โ€” real questions with worked answers.

  1. What is a function template in C++, and what keyword introduces it?

    A function template is a blueprint for generating a family of functions that operate on different data types without rewriting code. It is introduced with the `template` keyword followed by a parameter list, e.g. `template <typename T> T max(T a, T b);`.

  2. What is the difference between the keywords `typename` and `class` in a template parameter list?

    In a template parameter declaration (e.g. `template <typename T>` vs `template <class T>`) they are completely interchangeable and mean the same thing. `typename` is also required elsewhere to disambiguate a dependent type name inside a template.

  3. What is template argument deduction for function templates?

    It is the process by which the compiler automatically infers the template type parameters from the types of the function-call arguments, so you can write `max(3, 7)` instead of explicitly `max<int>(3, 7)`.

  4. When must you explicitly specify template arguments for a function template instead of relying on deduction?

    When the type cannot be deduced from the arguments (e.g. the type appears only in the return type or as a non-deduced context), when you need a different type than deduced, or for explicit conversion, e.g. `func<double>(2)`.

  5. What is a non-type template parameter? Give an example.

    A non-type template parameter is a compile-time constant value (not a type) passed to a template, such as an integer, pointer, or reference. Example: `template <typename T, int N> class Array { T data[N]; };` where `N` is a non-type parameter.

  6. What is a class template in C++?

    A class template is a blueprint for generating a family of classes parameterized on one or more types or values, allowing generic data structures. Example: `template <typename T> class Stack { ... };`, instantiated as `Stack<int>`.

  7. When are class templates instantiated, and why must their definitions usually be in header files?

    They are instantiated at compile time when used with concrete arguments (e.g. `Stack<int>`). Because the compiler must see the full definition to generate code for each instantiation, template definitions are typically placed entirely in header files rather than split into a .cpp file.

  8. How do you define a member function of a class template outside the class body?

    You prefix it with the template parameter list and qualify it with the templated class name, e.g. `template <typename T> void Stack<T>::push(const T& x) { ... }`.

  9. What is template specialization? Distinguish full (explicit) from partial specialization.

    Template specialization provides a custom implementation for specific template arguments. Full (explicit) specialization fixes all parameters (e.g. `template <> class Foo<char>`). Partial specialization fixes some parameters or narrows their form (e.g. `template <typename T> class Foo<T*>`); it is allowed for class templates but not function templates.

  10. What is the syntax for a full explicit specialization of a class template `template <typename T> class Foo`?

    `template <> class Foo<int> { ... };` โ€” an empty `template <>` parameter list followed by the class name with the concrete argument.

  11. Why can't function templates be partially specialized, and what is the recommended alternative?

    The C++ standard forbids partial specialization of function templates. The recommended alternative is function overloading (adding overloaded function templates) or delegating to a partially specialized class/struct template.

  12. What are the three keywords that make up C++ exception handling, and what does each do?

    `try` encloses code that may throw; `throw` raises an exception object; `catch` defines a handler that matches and handles a thrown exception of a given type.

  13. Describe the flow of control when an exception is thrown inside a `try` block.

    Execution of the try block stops immediately, the stack unwinds (destroying local objects), and control transfers to the first matching `catch` handler by type. If none matches in the current scope, unwinding propagates up the call stack until a handler is found or `std::terminate` is called.

  14. What is stack unwinding in the context of C++ exceptions?

    Stack unwinding is the process, during exception propagation, of destroying automatic (local) objects in reverse order of construction as each function's stack frame is exited, ensuring their destructors run and resources are released.

  15. How do you write a catch-all handler that catches any exception type?

    `catch (...) { ... }` โ€” the ellipsis matches exceptions of every type, but gives no access to the exception object itself.

  16. Why should exceptions generally be caught by reference (e.g. `catch (const std::exception& e)`)?

    Catching by reference avoids object slicing (which would lose the derived type's data/behavior when caught by value) and avoids an unnecessary copy, while still preserving polymorphic behavior via `what()`.

  17. What is the base class of the standard exception hierarchy, and what member function does it provide?

    `std::exception` (in `<exception>`) is the base class. It provides the virtual member function `what()`, which returns a `const char*` describing the error.

  18. Name and distinguish two standard exceptions derived from `std::logic_error` and two derived from `std::runtime_error`.

    From `std::logic_error` (errors detectable before run, in program logic): `std::invalid_argument`, `std::out_of_range`, `std::length_error`, `std::domain_error`. From `std::runtime_error` (errors detectable only at run time): `std::range_error`, `std::overflow_error`, `std::underflow_error`.

  19. Which standard exception does `std::vector::at()` throw on an invalid index, and which base class is it derived from?

    It throws `std::out_of_range`, which derives from `std::logic_error`, which in turn derives from `std::exception`.

  20. Which exception is thrown when `new` fails to allocate memory?

    `std::bad_alloc` (defined in `<new>`), which derives from `std::exception`.

  21. How do you create a user-defined exception class properly in C++?

    Derive it publicly from `std::exception` (or a subclass like `std::runtime_error`), and override `what()` as `const char* what() const noexcept override`. Deriving from `std::runtime_error` lets you pass a message string to its constructor and inherit `what()`.

  22. Why should a custom exception's `what()` override be marked `noexcept`?

    Because `std::exception::what()` is declared `noexcept`; an override must not throw. Marking it `noexcept` matches the base signature and guarantees the error-reporting path itself cannot throw during exception handling.

  23. What is a container in the C++ Standard Library, and what are the three broad categories?

    A container is a class template that stores and manages a collection of objects. The three categories are: sequence containers (`vector`, `deque`, `list`, `array`, `forward_list`), associative containers (`set`, `map`, `multiset`, `multimap`), and unordered associative containers (`unordered_set`, `unordered_map`, etc.). Container adaptors (`stack`, `queue`, `priority_queue`) are a fourth group.

  24. Compare `std::vector` and `std::list` in terms of storage and complexity.

    `std::vector` stores elements contiguously, giving $O(1)$ random access and amortized $O(1)$ push_back, but $O(n)$ insertion/deletion in the middle. `std::list` is a doubly linked list with $O(1)$ insertion/deletion anywhere (given an iterator) but no random access and $O(n)$ traversal to a position.

See more Advanced Topics flashcards โ†’

Planning Advanced Topics for C++ Programming

Advanced Topics is about 26% of the C++ Programming syllabus by topic count โ€” 17 of 65 topics, spread over 5 chapters. At roughly 45 minutes per topic plus 12 minutes per sub-topic, a first pass runs to about 15 hours.

The heaviest chapters are Standard Template Library (STL) (4 topics), File Handling (4 topics), Templates (3 topics) . Front-load those while your energy is high; the short chapters are better revision filler later.

Work top-down: read the chapter, then tick topics off individually rather than marking the whole chapter done. Sub-topics are where silent gaps hide.

Advanced Topics (C++ Programming) FAQ

What is in the C++ Programming Advanced Topics syllabus?

Advanced Topics is split into 5 chapters โ€” Templates, Exception Handling, Standard Template Library (STL), File Handling and Multithreading, containing 17 topics and 0 sub-topics in total.

How many chapters are there in Advanced Topics for C++ Programming?

5 chapters. Advanced Topics accounts for about 26% of the topics in the whole C++ Programming syllabus (17 of 65).

How long should I spend on Advanced Topics for C++ Programming?

Budget around 15 hours for a first pass through Advanced Topics โ€” about 45 minutes per topic plus 12 minutes per sub-topic across its 17 topics. Add revision cycles on top.

Are there flashcards for C++ Programming Advanced Topics?

Yes โ€” a 62-card Advanced Topics deck. Sample cards are printed on this page, and the full deck is free in the Examius app with spaced repetition scheduling.