gitGood.dev

C++ Interview Questions

Test your C++ knowledge with questions on memory management, STL, templates, RAII, smart pointers, and modern C++ features.

26
Total Questions
5
Easy
15
Medium
6
Hard
Showing 1-20 of 26 questionsPage 1 of 2
Sign up to start practicing these questionsSign up free →
RAII Pattern
QuizEasy
Smart Pointer Types
QuizEasy
Move Semantics
QuizMedium
Virtual Destructors
QuizEasy
Const Correctness
QuizMedium
Rule of Five
QuizMedium
Lvalues and Rvalues
QuizMedium
Templates vs Other Generics
QuizMedium
constexpr
QuizMedium
auto and decltype
QuizMedium
Perfect Forwarding
QuizHard
SFINAE
QuizHard
C++20 Concepts
QuizMedium
Lambda Capture
QuizMedium
Undefined Behavior
QuizMedium
Virtual Inheritance
QuizHard
Memory Ordering
QuizHard
Virtual Table (vtable)
QuizMedium
Structured Bindings
QuizEasy
std::optional
QuizEasy

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.

Explore Other Categories