Effective Modern C++ (Scott Meyers) — Item-by-Item Interview Notes Each item: Gist (what it says), Why (the reasoning), Interview angle (what to be ready to explain). Chapter 1: Deducing Types Item 1: Understand template type deduction Gist: For template<typename T> void f(ParamType param); f(expr); the deduced T depends on the form of ParamType . Three cases: Reference/pointer (not universal): ignore expr's reference-ness, then pattern-match. Constness of the argument is preserved in T ( f(T&) with a const int gives T = const int ). Universal reference ( T&& ): lvalue args make T and ParamType lvalue references; rvalues follow case 1. By value: ignore reference, then ignore const / volatile (the param is a copy). Arrays and functions decay to pointers when passed by value, but T& deduces the real array type including size ( const char(&)[13] ). This enables a constexpr arraySize template. Why: auto is built on these rules, ...
C++ Smart Pointer Interview Questions ( unique_ptr , shared_ptr , weak_ptr ) Senior interviews on smart pointers go well beyond "what is unique_ptr ?". Interviewers want to see that you understand ownership design, control-block mechanics, thread safety, performance costs, and the classic bugs. This set of 22 questions progresses from fundamentals to implementation-level topics, each with an interview-ready answer, explanation, and example. Fundamentals 1. What problem do smart pointers solve, and how do the three types differ? Smart pointers encode ownership in the type system and use RAII to release the resource automatically, including when exceptions are thrown. They largely eliminate manual delete , leaks, and double-frees. Type Ownership Copyable? Typical cost unique_ptr Exclusive (one owner) No (move only) Same as a raw pointer (with the default deleter) shared_ptr Shared (reference counted) Yes Control block + atomic reference counting ...