star iconstar iconstar iconstar iconstar icon

"Huge timesaver. Worth the money"

star iconstar iconstar iconstar iconstar icon

"It's an excellent tool"

star iconstar iconstar iconstar iconstar icon

"Fantastic catalogue of questions"

Ace your next tech interview with confidence

Explore our carefully curated catalog of interview essentials covering full-stack, data structures and algorithms, system design, data science, and machine learning interview questions

C++

100 C++ interview questions

Only coding challenges
Topic progress: 0%

C++ Basics and Language Features


  • 1.

    What are the main features of C++?

    Answer:
  • 2.

    Explain the difference between C and C++.

    Answer:
  • 3.

    What is object-oriented programming in C++?

    Answer:
  • 4.

    What are the access specifiers in C++ and what do they do?

    Answer:
  • 5.

    Explain the concept of namespaces in C++.

    Answer:
  • 6.

    What is the difference between ‘struct’ and ‘class’ in C++?

    Answer:
  • 7.

    What is a constructor and what are its types in C++?

    Answer:
  • 8.

    Explain the concept of destructors in C++.

    Answer:
  • 9.

    What is function overloading in C++?

    Answer:
  • 10.

    What is operator overloading in C++?

    Answer:

Memory Management and Pointers


  • 11.

    What is dynamic memory allocation in C++?

    Answer:
  • 12.

    Explain the difference between ‘new’ and ‘malloc()’.

    Answer:
  • 13.

    What is a memory leak and how can it be prevented?

    Answer:
  • 14.

    What is a dangling pointer?

    Answer:
  • 15.

    Explain the concept of smart pointers in C++.

    Answer:
  • 16.

    What is the difference between unique_ptr, shared_ptr, and weak_ptr?

    Lock icon indicating premium question
    Answer:
  • 17.

    How does reference counting work in shared_ptr?

    Lock icon indicating premium question
    Answer:
  • 18.

    What is the rule of three in C++?

    Lock icon indicating premium question
    Answer:
  • 19.

    What is the rule of five in C++?

    Lock icon indicating premium question
    Answer:
  • 20.

    Explain move semantics in C++.

    Lock icon indicating premium question
    Answer:

Object-Oriented Programming Concepts


  • 21.

    What is inheritance in C++? Explain its types.

    Lock icon indicating premium question
    Answer:
  • 22.

    What is polymorphism and how is it implemented in C++?

    Lock icon indicating premium question
    Answer:
  • 23.

    Explain the concept of virtual functions in C++.

    Lock icon indicating premium question
    Answer:
  • 24.

    What is a pure virtual function?

    Lock icon indicating premium question
    Answer:
  • 25.

    What is an abstract class in C++?

    Lock icon indicating premium question
    Answer:
  • 26.

    Explain the diamond problem in multiple inheritance and how to solve it.

    Lock icon indicating premium question
    Answer:
  • 27.

    What is function hiding in C++?

    Lock icon indicating premium question
    Answer:
  • 28.

    Explain the concept of friend functions and classes.

    Lock icon indicating premium question
    Answer:
  • 29.

    What is the difference between composition and inheritance?

    Lock icon indicating premium question
    Answer:
  • 30.

    What is RAII (Resource Acquisition Is Initialization) in C++?

    Lock icon indicating premium question
    Answer:

Templates and Generic Programming


  • 31.

    What are templates in C++?

    Lock icon indicating premium question
    Answer:
  • 32.

    Explain the difference between function templates and class templates.

    Lock icon indicating premium question
    Answer:
  • 33.

    What is template specialization?

    Lock icon indicating premium question
    Answer:
  • 34.

    How does template metaprogramming work in C++?

    Lock icon indicating premium question
    Answer:
  • 35.

    What are variadic templates?

    Lock icon indicating premium question
    Answer:
  • 36.

    Explain the concept of type traits in C++.

    Lock icon indicating premium question
    Answer:
  • 37.

    What is SFINAE (Substitution Failure Is Not An Error)?

    Lock icon indicating premium question
    Answer:
  • 38.

    How do you implement a type-safe container using templates?

    Lock icon indicating premium question
    Answer:
  • 39.

    What are the advantages and disadvantages of using templates?

    Lock icon indicating premium question
    Answer:
  • 40.

    Explain the concept of template argument deduction.

    Lock icon indicating premium question
    Answer:

Exception Handling


  • 41.

    What is exception handling in C++?

    Lock icon indicating premium question
    Answer:
  • 42.

    Explain the try, catch, and throw keywords.

    Lock icon indicating premium question
    Answer:
  • 43.

    What is the purpose of the ‘noexcept’ specifier?

    Lock icon indicating premium question
    Answer:
  • 44.

    How do you create custom exception classes?

    Lock icon indicating premium question
    Answer:
  • 45.

    What happens if an exception is not caught?

    Lock icon indicating premium question
    Answer:
  • 46.

    Explain the concept of exception safety.

    Lock icon indicating premium question
    Answer:
  • 47.

    What is the difference between synchronous and asynchronous exceptions?

    Lock icon indicating premium question
    Answer:
  • 48.

    How do you handle constructor failures using exceptions?

    Lock icon indicating premium question
    Answer:
  • 49.

    What is the purpose of std::exception and its derived classes?

    Lock icon indicating premium question
    Answer:
  • 50.

    How do you implement a stack unwinding mechanism?

    Lock icon indicating premium question
    Answer:

Standard Template Library (STL)


  • 51.

    What is the Standard Template Library (STL)?

    Lock icon indicating premium question
    Answer:
  • 52.

    Explain the difference between vector and list in STL.

    Lock icon indicating premium question
    Answer:
  • 53.

    What are the associative containers in STL?

    Lock icon indicating premium question
    Answer:
  • 54.

    How does an unordered_map work internally?

    Lock icon indicating premium question
    Answer:
  • 55.

    What is the difference between set and multiset?

    Lock icon indicating premium question
    Answer:
  • 56.

    Explain the concept of iterators in STL.

    Lock icon indicating premium question
    Answer:
  • 57.

    What are function objects (functors) in STL?

    Lock icon indicating premium question
    Answer:
  • 58.

    How do you use algorithms like sort, find, and binary_search in STL?

    Lock icon indicating premium question
    Answer:
  • 59.

    What is the purpose of std::pair and std::tuple?

    Lock icon indicating premium question
    Answer:
  • 60.

    Explain the concept of allocators in STL.

    Lock icon indicating premium question
    Answer:

Concurrency and Multithreading


  • 61.

    What is multithreading in C++?

    Lock icon indicating premium question
    Answer:
  • 62.

    How do you create and manage threads using std::thread?

    Lock icon indicating premium question
    Answer:
  • 63.

    Explain the concept of mutex and its types in C++.

    Lock icon indicating premium question
    Answer:
  • 64.

    What is a deadlock and how can it be prevented?

    Lock icon indicating premium question
    Answer:
  • 65.

    How do you use condition variables for thread synchronization?

    Lock icon indicating premium question
    Answer:
  • 66.

    What is the purpose of std::atomic?

    Lock icon indicating premium question
    Answer:
  • 67.

    Explain the difference between std::async and std::thread.

    Lock icon indicating premium question
    Answer:
  • 68.

    What is a thread pool and how would you implement one?

    Lock icon indicating premium question
    Answer:
  • 69.

    How do you handle race conditions in C++?

    Lock icon indicating premium question
    Answer:
  • 70.

    Explain the concept of memory ordering in C++ concurrency.

    Lock icon indicating premium question
    Answer:

C++11 and Beyond Features


  • 71.

    What are lambda expressions in C++?

    Lock icon indicating premium question
    Answer:
  • 72.

    Explain the ‘auto’ keyword and type inference.

    Lock icon indicating premium question
    Answer:
  • 73.

    What is uniform initialization in C++11?

    Lock icon indicating premium question
    Answer:
  • 74.

    How does range-based for loop work?

    Lock icon indicating premium question
    Answer:
  • 75.

    What are delegating constructors?

    Lock icon indicating premium question
    Answer:
  • 76.

    Explain the concept of rvalue references.

    Lock icon indicating premium question
    Answer:
  • 77.

    What is perfect forwarding in C++?

    Lock icon indicating premium question
    Answer:
  • 78.

    How do you use std::chrono for time-related operations?

    Lock icon indicating premium question
    Answer:
  • 79.

    What are the improvements in smart pointers introduced in C++11?

    Lock icon indicating premium question
    Answer:
  • 80.

    Explain the concept of constexpr.

    Lock icon indicating premium question
    Answer:

Advanced C++ Concepts


  • 81.

    What is CRTP (Curiously Recurring Template Pattern)?

    Lock icon indicating premium question
    Answer:
  • 82.

    Explain the concept of type erasure in C++.

    Lock icon indicating premium question
    Answer:
  • 83.

    What are fold expressions in C++17?

    Lock icon indicating premium question
    Answer:
  • 84.

    How do you implement a singleton pattern in C++?

    Lock icon indicating premium question
    Answer:
  • 85.

    What is the purpose of std::optional?

    Lock icon indicating premium question
    Answer:
  • 86.

    Explain the concept of concepts in C++20.

    Lock icon indicating premium question
    Answer:
  • 87.

    What are coroutines in C++20?

    Lock icon indicating premium question
    Answer:
  • 88.

    How do you use std::variant and std::visit?

    Lock icon indicating premium question
    Answer:
  • 89.

    What is the purpose of std::any?

    Lock icon indicating premium question
    Answer:
  • 90.

    Explain the concept of modules in C++20.

    Lock icon indicating premium question
    Answer:

Performance and Optimization


  • 91.

    What is cache coherence and how does it affect C++ program performance?

    Lock icon indicating premium question
    Answer:
  • 92.

    How do you optimize memory usage in C++ programs?

    Lock icon indicating premium question
    Answer:
  • 93.

    Explain the concept of branch prediction and its impact on performance.

    Lock icon indicating premium question
    Answer:
  • 94.

    What is loop unrolling and when is it beneficial?

    Lock icon indicating premium question
    Answer:
  • 95.

    How do you profile C++ code for performance optimization?

    Lock icon indicating premium question
    Answer:
  • 96.

    What is the difference between constexpr and inline functions in terms of performance?

    Lock icon indicating premium question
    Answer:
  • 97.

    Explain the concept of false sharing and how to avoid it.

    Lock icon indicating premium question
    Answer:
  • 98.

    How do you optimize code for modern CPU architectures (e.g., SIMD instructions)?

    Lock icon indicating premium question
    Answer:
  • 99.

    What are some techniques for reducing compile times in large C++ projects?

    Lock icon indicating premium question
    Answer:
  • 100.

    How do you implement and use lock-free data structures for better concurrency performance?

    Lock icon indicating premium question
    Answer:
folder icon

Unlock interview insights

Get the inside track on what to expect in your next interview. Access a collection of high quality technical interview questions with detailed answers to help you prepare for your next coding interview.

graph icon

Track progress

Simple interface helps to track your learning progress. Easily navigate through the wide range of questions and focus on key topics you need for your interview success.

clock icon

Save time

Save countless hours searching for information on hundreds of low-quality sites designed to drive traffic and make money from advertising.

Land a six-figure job at one of the top tech companies

amazon logometa logogoogle logomicrosoft logoopenai logo
Ready to nail your next interview?

Stand out and get your dream job

scroll up button

Go up