C++ Technical Round Questions & Answers
40 questions for the technical round stage — 4 easy, 32 medium, 4 hard.
About the technical round round
The technical round is the core of a C++ interview: concept questions with follow-ups, a live hands-on task and a deep dive into one of your projects. Interviewers check depth, not just definitions.
Tips for the technical round round
- Say your approach out loud before you start writing.
- After a correct answer, expect 'why?' and 'what if?' follow-ups; go one level deeper than the question.
- Pick one project you can explain end to end, including what you would do differently.
- If you get stuck, explain what you would try next instead of going silent.
Explain move semantics and what std::move actually does.
Show answer
Write a GoogleTest unit test for a function, including an edge case.
Show answer
Remove duplicates from a vector of integers.
Show answer
What is the difference between push_back and emplace_back?
Show answer
Write a custom hash so a struct can be used as a key in std::unordered_map.
Show answer
What is the difference between const and constexpr?
Show answer
Use a C++20 ranges pipeline to get squares of the first three even numbers.
Show answer
What are lvalues and rvalues?
Show answer
When are std::vector iterators invalidated?
Show answer
A function taking a Money object is silently called with an int and gives wrong results. What is happening?
Show answer
What is function overloading and how does the compiler choose an overload?
Show answer
Reverse a singly linked list using pointers.
Show answer
What are the iterator categories in C++?
Show answer
When would you use std::set versus std::priority_queue?
Show answer
List the gdb commands you would use to debug a crash.
Show answer
What is the diamond problem and how does virtual inheritance solve it?
Show answer
Sorting a vector of large objects is slow. What can you do?
Show answer
How do you decide between templates and virtual functions for polymorphism?
Show answer
Use std::variant and std::visit to handle different message types.
Show answer
What are std::optional, std::variant and std::any?
Show answer
What is CMake and why is it used for C++ projects?
Show answer
What does C++20 std::jthread add over std::thread?
Show answer
You are asked to modernise a large C++98 codebase to C++17. How would you plan it?
Show answer
Write a deadlock-free money transfer between two bank accounts.
Show answer
Should a Car class inherit from Engine or contain an Engine? Explain your choice.
Show answer
How do virtual functions work internally?
Show answer
Why should you prefer make_unique and make_shared over calling new directly?
Show answer
Which profiling tools do you use for C++ and what does each show?
Show answer
A full build of your C++ project takes 40 minutes. How would you reduce it?
Show answer
Compare std::mutex, lock_guard, unique_lock and scoped_lock.
Show answer
What is the erase-remove idiom and what replaced it in C++20?
Show answer
What is object slicing?
Show answer
The release binary has grown very large and analysis shows many template instantiations. What can you do?
Show answer
A service occasionally freezes and thread dumps show two threads each waiting on a mutex held by the other. How do you fix it?
Show answer
Use lambdas with standard algorithms to sort strings by length and count those longer than a limit.
Show answer
What is a deadlock and how do you prevent it?
Show answer
What is cache locality and why does it matter for performance?
Show answer
Four threads each increment a shared int one million times, but the final total is less than four million. Why?
Show answer
How would you choose between exceptions, error codes and std::expected for error handling?
Show answer
Frequently asked questions
What happens in the C++ technical round round?
The technical round is the core of a C++ interview: concept questions with follow-ups, a live hands-on task and a deep dive into one of your projects. Interviewers check depth, not just definitions.
How do I clear the technical round round?
Say your approach out loud before you start writing. After a correct answer, expect 'why?' and 'what if?' follow-ups; go one level deeper than the question. Pick one project you can explain end to end, including what you would do differently.
Which round comes next?
A typical order is online assessment, telephonic screening, one or two technical rounds, a managerial round and HR. Use the other round pages to practise each stage.