C++ & STL Interview Questions
Pointers and references, RAII, rule of five, move semantics, vtables, smart pointers, and STL containers.
30 questions in this section
- What are the key differences between C and C++, and between struct and class? (Beginner)
- References vs pointers in C++ (Beginner)
- const pointer vs pointer to const, and const correctness (Beginner)
- Stack vs heap memory in C++ (Beginner)
- new/delete vs malloc/free (Beginner)
- Memory leaks, dangling pointers and double free (Intermediate)
- RAII: Resource Acquisition Is Initialization (Intermediate)
- Constructors in C++: default, copy and move (Intermediate)
- Shallow copy vs deep copy (Beginner)
- Rule of three, rule of five and rule of zero (Advanced)
- Lvalues, rvalues and move semantics (Intermediate)
- Copy elision, RVO and NRVO (Advanced)
- std::move vs std::forward and perfect forwarding (Advanced)
- Virtual functions, vtable and vptr (Intermediate)
- Pure virtual functions and abstract classes (Beginner)
- Why do base classes need a virtual destructor? (Intermediate)
- Object slicing (Intermediate)
- Function overloading vs overriding (and name hiding) (Beginner)
- Operator overloading in C++ (Intermediate)
- Friend functions and inline functions (Intermediate)
- Templates and template specialization (Advanced)
- Smart pointers: unique_ptr and shared_ptr (Intermediate)
- weak_ptr and breaking shared_ptr cycles (Advanced)
- vector growth and iterator invalidation (Intermediate)
- map vs unordered_map, and choosing an STL container (Intermediate)
- STL algorithms and priority_queue: sort, lower_bound, heaps (Intermediate)
- Lambdas and capture modes (Advanced)
- The static keyword and its different meanings (Beginner)
- Undefined behaviour: common examples and how to avoid it (Advanced)
- Tricky C++ output questions (Advanced)