C++ Interview Questions
Test your C++ knowledge with questions on memory management, STL, templates, RAII, smart pointers, and modern C++ features.
Frequently Asked Questions
What C++ topics are most important for interviews?
Memory management (new/delete, smart pointers), STL containers and algorithms, templates, RAII, copy/move semantics, virtual functions and polymorphism, operator overloading, and modern C++ features (auto, lambda, range-based for, constexpr). For game dev, also know memory pools and cache optimization.
Which companies test C++ in interviews?
Companies working on performance-critical software: game studios (Epic, Blizzard), trading firms (Citadel, Two Sigma), embedded systems companies, browser teams (Chrome, Firefox), and companies building databases, compilers, or operating systems. Google and Meta also use C++ extensively.
What are smart pointers and when should I use each type?
unique_ptr has sole ownership and is the default choice. shared_ptr uses reference counting for shared ownership. weak_ptr breaks circular references with shared_ptr. Use unique_ptr unless you genuinely need shared ownership. Avoid raw new/delete in modern C++.
What is RAII and why is it important?
Resource Acquisition Is Initialization ties resource lifetime to object lifetime. Resources (memory, files, locks) are acquired in constructors and released in destructors. This guarantees cleanup even when exceptions occur. RAII is the foundation of safe C++ resource management.
What is the difference between copy and move semantics?
Copy creates a duplicate of data (expensive for large objects). Move transfers ownership of resources without copying (cheap - just pointer swaps). Move semantics were introduced in C++11 with rvalue references (&&) and std::move. They dramatically improve performance for containers and return values.
What are templates and how are they used?
Templates enable generic programming - writing code that works with any type. Function templates and class templates are instantiated at compile time for each type used. Template specialization handles specific types differently. Modern C++ adds concepts (C++20) to constrain template parameters.