CPP Cheat Sheet 2026
The 30 highest-yield CPP facts, distilled from real exam questions. Print it, save it as a PDF, or study it here — free, no sign-up.
70 questions
120 min time limit
70% to pass
- How should CPP professionals measure success in performance optimization & profiling? → Using defined metrics, benchmarks, and regular evaluation against established goals
- Which STL container provides constant-time access by index and automatic resizing? → std::vector
- What is the key difference between composition and inheritance as design strategies? → Composition models a 'has-a' relationship; inheritance models an 'is-a' relationship
- What does write() return when it encounters an error? → -1
- Which of the following statements about std::array is TRUE? → Its size is fixed at compile time and it is stack-allocated by default
- Which method of std::map returns an iterator to an element if found, or end() if not? → find()
- What is the conventional return type for the copy assignment operator (operator=)? → T&
- Which SOLID principle does the Open/Closed Principle (OCP) describe? → Software entities should be open for extension but closed for modification
- What does the '*' operator do when used with pointers? → Returns the value stored at the memory address
- What is the result of the fold expression `(args + ...)` when args is an empty pack? → Compilation error for operator+
- What does the RAII idiom guarantee in C++ memory management? → Resources are acquired in a constructor and released in the corresponding destructor
- What happens when you delete a pointer that was not allocated with new? → It is undefined behavior
- What does the 'explicit' keyword do when applied to a constructor? → Prevents the constructor from being used for implicit type conversions
- Which algorithm computes the sum of a range sequentially from left to right? → std::accumulate
- What happens when an exception is thrown inside a destructor that is already executing due to stack unwinding? → std::terminate() is called
- What does the ThreadSanitizer (TSan) detect in C++ multithreaded applications? → Data races where two threads access shared memory without synchronization
- Which of the following is NOT a valid use of catch(...)? → Accessing the caught exception object's members
- What does the C++17 structured binding `auto [x, y] = std::make_pair(1, 2.0);` deduce for `x` and `y`? → x is int, y is double
- What is the relationship between unit testing & code quality and overall C++ Programming Professional Certificate professional competency? → It is an essential component that strengthens the overall competency framework
- What does 'false sharing' mean in the context of multi-threaded performance? → Threads access different variables that reside on the same cache line
- What is the relationship between templates & generic programming and overall C++ Programming Professional Certificate professional competency? → It is an essential component that strengthens the overall competency framework
- What is the purpose of `std::enable_if` in template programming? → To conditionally enable a template specialization based on a compile-time boolean
- What is the purpose of std::allocator in C++? → To provide a customizable memory allocation strategy for containers
- Which sorting algorithm does std::stable_sort typically use? → Merge sort
- Which file stream method returns the current position of the get pointer? → tellg()
- Which cache concept refers to the tendency of programs to access memory locations near recently accessed locations? → Spatial locality
- What is the relationship between concurrency & multithreading and overall C++ Programming Professional Certificate professional competency? → It is an essential component that strengthens the overall competency framework
- What is the effect of declaring a move constructor as noexcept on container operations like std::vector resize? → The vector will use the move constructor instead of copy constructor during reallocation
- What is the relationship between build systems & package management and overall C++ Programming Professional Certificate professional competency? → It is an essential component that strengthens the overall competency framework
- What does `make -j$(nproc)` accomplish on a Linux system? → Launches parallel make jobs up to the number of available CPU cores
Turn these facts into recall:
Was this helpful?