Skip to content

Easy C++ Interview Questions

60 easy questions with answers. Definitions and fundamentals every candidate must answer quickly and correctly.

Topics in the easy set

C++ Basics and Syntax: 13 Pointers and Memory Management: 7 Standard Template Library (STL): 7 Modern C++ (C++11 to C++23): 7 Multithreading and Concurrency: 7 Performance, Debugging and Build Tools: 7 Object-Oriented Programming in C++: 6 Templates and Generic Programming: 6
Solved — easyStart practicing
3 QUESTIONS FREESign up to unlock the full question bank and track your progress.Unlock every question and answer, then continue practising company-wise and package-wise.
3 questions free Unlock the rest in seconds
01

What is C++ and how is it different from C?

Save to ▾
Show answer
C++ is a compiled, statically typed, multi-paradigm language built on top of C. It adds classes, inheritance, templates, exceptions, namespaces, references, function overloading and a large Standard Library, while C is purely procedural. C++ keeps the low-level control and speed of C, which is why it is used in game engines, trading systems, browsers, databases, compilers and embedded firmware where performance and hardware access matter.
02

What is the difference between a declaration and a definition?

Save to ▾
Show answer
A declaration tells the compiler that a name of a certain type exists, for example extern int count; or void f(int);. A definition actually allocates storage or provides the function body. You may declare a name many times but define it only once across the whole program, which is the One Definition Rule. Headers normally hold declarations and .cpp files hold definitions.
03

What are the fundamental data types in C++ and their typical sizes?

Save to ▾
Show answer
The main types are bool, char, short, int, long, long long, float, double and long double. On a typical 64-bit Linux system char is 1 byte, short 2, int 4, long 8, long long 8, float 4 and double 8. The standard only guarantees minimum ranges, so check with sizeof, and use fixed-width types such as int32_t or uint64_t from <cstdint> when the exact size matters.
04

What is the difference between ++i and i++?

Save to ▾
Show answer
++i increments the variable and returns the updated object, while i++ returns a copy of the old value and then increments. For an int the optimiser makes them equally fast. For iterators and class types i++ must create a temporary copy, so ++i is preferred in loops. Example: int a = 5; int b = a++; leaves b equal to 5 and a equal to 6.
05

A teammate added using namespace std; to a shared header file. What problems can this cause?

Save to ▾
Show answer
Every file that includes the header now has all std names pulled into the global namespace. This can cause ambiguous calls or silently pick the wrong function when user code defines names like count, distance, min or data. The problem spreads to every dependent file and is hard to trace. I would remove it and use explicit std:: qualification or narrow using declarations inside .cpp files or function bodies.
06

What are default arguments and what rules apply to them?

Save to ▾
Show answer
Default arguments supply values when a caller leaves out trailing arguments, for example void log(const std::string& msg, int level = 1);. Defaults must appear at the end of the parameter list and be given only once, usually in the header declaration. They are bound at compile time, so for a virtual function the default value comes from the static type of the pointer, not the dynamic type, which is a common trap.
07

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

Save to ▾
Show answer
The only language difference is default access. Members and base classes of a struct are public by default, while in a class they are private by default. Both can have constructors, member functions, inheritance and templates. By convention a struct is used for simple data aggregates such as a Point, and a class is used for types that protect invariants with private state.
08

Compare pass by value, pass by pointer and pass by reference.

Save to ▾
Show answer
Pass by value copies the argument, so changes inside the function do not affect the caller. Pass by pointer passes an address, can be null and needs dereferencing. Pass by reference creates an alias that cannot be null and uses normal syntax. A good rule: pass small types such as int by value, large read-only objects by const reference, and use a non-const reference or pointer for output parameters.
09

Write a function to reverse a string in place without using std::reverse.

Save to ▾
Show answer
#include <string> #include <utility> void reverseInPlace(std::string& s) { if (s.empty()) return; std::size_t i = 0, j = s.size() - 1; while (i < j) { std::swap(s[i], s[j]); ++i; --j; } } // Two pointers meet in the middle: O(n) time, O(1) extra space.
10

Write an efficient function to check whether a number is prime.

Save to ▾
Show answer
bool isPrime(long long n) { if (n < 2) return false; if (n % 2 == 0) return n == 2; for (long long i = 3; i * i <= n; i += 2) { if (n % i == 0) return false; } return true; } // Only odd divisors up to sqrt(n) are checked: O(sqrt n) time.
11

Write a swap function using references and explain why a pass-by-value version fails.

Save to ▾
Show answer
void swapByValue(int a, int b) { // works on copies, caller sees no change int t = a; a = b; b = t; } void swapByRef(int& a, int& b) { // a and b alias the caller's variables int t = a; a = b; b = t; } int x = 1, y = 2; swapByRef(x, y); // now x == 2, y == 1
12

Why did you choose C++ for your career instead of a language like Python or Java?

Save to ▾
Show answer
Situation: in college I built a small game and a file compressor in Python and hit performance limits. Task: I wanted to understand what happens closer to the hardware. Action: I learned C++ properly, including memory management, STL and multithreading, and rewrote the compressor. Result: it ran about ten times faster and I understood systems much better. I enjoy work where that control matters, while I still use Python for scripting.
13

A program that prints a million lines with std::endl is very slow. Why, and how do you fix it?

Save to ▾
Show answer
std::endl writes a newline and also flushes the stream buffer every time, forcing a system call per line. Replace it with the newline character so output is buffered and written in large chunks. For competitive programming or bulk output, also call std::ios::sync_with_stdio(false) and std::cin.tie(nullptr). Flush explicitly only when output must appear immediately, such as before a risky operation.
14

What is a pointer and how is it different from a reference?

Save to ▾
Show answer
A pointer is a variable that stores a memory address; it can be null, can be reassigned and supports arithmetic. A reference is an alias for an existing object; it must be initialised, cannot be reseated to another object and cannot be null in valid code. Pointers suit optional values, arrays and dynamic memory, while references give clean syntax for parameters and operator overloading.
15

What is the difference between stack and heap memory?

Save to ▾
Show answer
Stack memory holds local variables and call frames; allocation is very fast and automatic, and memory is freed when the scope ends, but the size is limited to a few megabytes. Heap memory is allocated at run time with new or by containers, is much larger and lives until it is freed, but allocation is slower and can fragment. Large, variable-size or long-lived objects belong on the heap.
16

What is a dangling pointer?

Save to ▾
Show answer
A dangling pointer points to memory that has already been freed or has gone out of scope, for example the address of a local variable returned from a function, or a pointer used after delete. Dereferencing it is undefined behaviour and may crash much later in unrelated code. Prevent it with smart pointers, clear ownership rules and by never returning addresses of local variables.
17

What is pointer arithmetic?

Save to ▾
Show answer
Adding an integer to a pointer moves it by that many elements, not bytes, so p + 1 on an int* advances by sizeof(int) bytes. Subtracting two pointers into the same array gives the number of elements between them as ptrdiff_t. Arithmetic is only valid inside an array or one past its end; moving beyond that is undefined behaviour. Contiguous iterators work on the same idea.
18

What is the difference between delete and delete[]?

Save to ▾
Show answer
delete destroys a single object created with new. delete[] destroys an array created with new[] and calls the destructor of every element, using an element count the runtime stores with the allocation. Using delete on an array or delete[] on a single object is undefined behaviour and can leak or corrupt the heap. In modern code std::vector or std::unique_ptr<T[]> removes the need for either.
19

What is a void pointer and when would you use it?

Save to ▾
Show answer
A void* can hold the address of any object type but cannot be dereferenced or used in arithmetic until it is cast back to a real type. It appears in C APIs such as malloc, memcpy and callback user-data parameters. In C++ code, templates, std::any or std::variant are better because void* removes type safety and mistakes appear only at run time.
20

Find the middle node of a linked list in a single pass.

Save to ▾
Show answer
Node* middle(Node* head) { Node* slow = head; Node* fast = head; while (fast && fast->next) { slow = slow->next; fast = fast->next->next; } return slow; } // fast moves two steps and slow one step, so slow stops at the middle.
21

What are the four pillars of object-oriented programming in C++?

Save to ▾
Show answer
Encapsulation hides data behind a class interface using private members and public methods. Abstraction exposes only what users need, often through abstract base classes. Inheritance lets a derived class reuse and extend a base class. Polymorphism lets one interface behave differently: compile-time through overloading and templates, run-time through virtual functions. Together they help model systems such as bank accounts, shapes or payment methods cleanly.
22

What kinds of constructors does C++ have?

Save to ▾
Show answer
A default constructor takes no arguments. A parameterised constructor takes arguments to initialise members. A copy constructor, T(const T&), creates an object from another of the same type. A move constructor, T(T&&), steals resources from a temporary. There are also delegating constructors that call another constructor and converting constructors that take one argument; mark those explicit to avoid unwanted implicit conversions.
23

What is a pure virtual function and an abstract class?

Save to ▾
Show answer
A pure virtual function is declared with = 0, such as virtual double area() const = 0;, and has no required implementation in the base. A class with at least one pure virtual function is abstract and cannot be instantiated; it only defines an interface. Derived classes must override every pure virtual function to become concrete. This is how C++ expresses interfaces like Shape or PaymentGateway.
24

What is the difference between overloading and overriding, and what do override and final do?

Save to ▾
Show answer
Overloading means same name, different parameters, resolved at compile time within one scope. Overriding means a derived class replaces a base virtual function with the same signature, resolved at run time. The override keyword makes the compiler check that a matching base virtual exists, catching typos and const mismatches. final stops further overriding of a function or further inheritance from a class.
25

Write a Shape hierarchy with a virtual area function and use it polymorphically.

Save to ▾
Show answer
#include <iostream> #include <memory> #include <vector> struct Shape { virtual ~Shape() = default; virtual double area() const = 0; }; struct Circle : Shape { double r; explicit Circle(double r) : r(r) {} double area() const override { return 3.14159 * r * r; } }; struct Rect : Shape { double w, h; Rect(double w, double h) : w(w), h(h) {} double area() const override { return w * h; } }; int main() { std::vector<std::unique_ptr<Shape>> v; v.push_back(std::make_unique<Circle>(2)); v.push_back(std::make_unique<Rect>(3, 4)); for (const auto& s : v) std::cout << s->area() << '\n'; }
26

How would you explain polymorphism to a junior developer who has just joined your team?

Save to ▾
Show answer
Situation: a new joiner was confused by virtual functions in our codebase. Task: help them become productive quickly. Action: I used a real example from our code, a Notifier base class with Email and Sms versions, drew how the vtable decides the call at run time, and gave them a small task to add a WhatsApp notifier. Result: they finished it in a day and later explained the idea to the next intern.
27

What are templates in C++? Explain function and class templates.

Save to ▾
Show answer
Templates let you write code once for many types; the compiler generates a concrete version for each type used. A function template such as template <typename T> T maxOf(T a, T b) works for int, double or std::string. A class template such as template <typename T> class Stack builds containers for any element type. The whole STL, including vector, map and algorithms, is built on templates.
28

What are non-type template parameters?

Save to ▾
Show answer
Template parameters can be values, not just types, as long as they are compile-time constants, such as integers, enums, pointers and, since C++20, some class types. std::array<int, 5> uses a size parameter. Example: template <int N> int power(int x) can be unrolled by the compiler. Each different value creates a separate instantiation, so they suit small fixed sets of values.
29

Write a generic function template that returns the larger of two values.

Save to ▾
Show answer
template <typename T> const T& maxOf(const T& a, const T& b) { return (a < b) ? b : a; } // usage int m = maxOf(3, 7); // T = int double d = maxOf(2.5, 1.5); // T = double auto s = maxOf<double>(3, 4.5); // explicit T avoids deduction conflict
30

Implement a generic Stack class template backed by std::vector.

Save to ▾
Show answer
#include <stdexcept> #include <vector> template <typename T> class Stack { std::vector<T> items_; public: void push(const T& x) { items_.push_back(x); } void push(T&& x) { items_.push_back(std::move(x)); } void pop() { if (items_.empty()) throw std::out_of_range("empty stack"); items_.pop_back(); } const T& top() const { return items_.back(); } bool empty() const { return items_.empty(); } std::size_t size() const { return items_.size(); } };
31

Compute a factorial at compile time.

Save to ▾
Show answer
constexpr unsigned long long factorial(unsigned n) { unsigned long long r = 1; for (unsigned i = 2; i <= n; ++i) r *= i; return r; } static_assert(factorial(5) == 120); constexpr auto f10 = factorial(10); // computed by the compiler // Pre-C++14 style used template recursion: // template <unsigned N> struct Fact { static const unsigned long long v = N * Fact<N - 1>::v; }; // template <> struct Fact<0> { static const unsigned long long v = 1; };
32

How do you keep your C++ knowledge up to date with new standards?

Save to ▾
Show answer
Situation: I noticed many tutorials still teach C++98 style. Task: learn modern practices properly. Action: I follow cppreference for each new standard, watch selected conference talks, read the C++ Core Guidelines and try features such as concepts, ranges and std::format in small practice projects compiled with recent GCC and Clang. Result: I can explain when a modern feature helps and when older code is fine.
33

What are the main components of the Standard Template Library?

Save to ▾
Show answer
The STL has four parts. Containers store data, such as vector, deque, list, map, set and unordered_map. Iterators give a uniform way to traverse containers. Algorithms such as sort, find, accumulate and lower_bound work on iterator ranges. Function objects and lambdas customise algorithms, for example a comparator for sort. Adapters such as stack, queue and priority_queue wrap other containers.
34

Compare std::vector, std::list and std::deque.

Save to ▾
Show answer
vector stores elements contiguously, gives O(1) random access and fast iteration, with amortised O(1) push_back but O(n) insertion in the middle. list is a doubly linked list with O(1) insert and erase anywhere given an iterator, but no random access and poor cache use. deque supports fast insertion at both ends and random access, stored in chunks. Default to vector unless profiling says otherwise.
35

What is the difference between std::map and std::unordered_map?

Save to ▾
Show answer
std::map is usually a red-black tree: keys are kept sorted and lookup, insert and erase are O(log n). std::unordered_map is a hash table with average O(1) operations but no ordering, and worst case O(n) with many collisions. Use map when you need ordered iteration or range queries like lower_bound, and unordered_map for fast key lookups where order does not matter.
36

Sort a vector of pairs by the second value in descending order, breaking ties by the first value.

Save to ▾
Show answer
#include <algorithm> #include <vector> std::vector<std::pair<int, int>> v = {{1, 5}, {2, 3}, {3, 5}}; std::sort(v.begin(), v.end(), [](const auto& a, const auto& b) { if (a.second != b.second) return a.second > b.second; return a.first < b.first; }); // Result: {1,5} {3,5} {2,3}. The comparator must be a strict weak ordering.
37

Solve two sum: return indices of two numbers that add up to a target.

Save to ▾
Show answer
#include <unordered_map> #include <vector> std::vector<int> twoSum(const std::vector<int>& nums, int target) { std::unordered_map<int, int> seen; // value -> index for (int i = 0; i < static_cast<int>(nums.size()); ++i) { auto it = seen.find(target - nums[i]); if (it != seen.end()) return {it->second, i}; seen[nums[i]] = i; } return {}; } // O(n) time, O(n) space.
38

Remove duplicates from a vector of integers.

Save to ▾
Show answer
#include <algorithm> #include <vector> void dedupSorted(std::vector<int>& v) { std::sort(v.begin(), v.end()); v.erase(std::unique(v.begin(), v.end()), v.end()); } // O(n log n). std::unique only removes adjacent duplicates, so sort first. // To keep the original order, track seen values in an unordered_set instead.
39

Describe a time you had to learn a new library or API quickly.

Save to ▾
Show answer
Situation: during my internship I was asked to fix a bug in code using Boost.Asio, which I had never used. Task: understand enough to fix it within the sprint. Action: I read the official examples, wrote a tiny echo server to learn the async model, then traced the bug to a missing handler for connection timeouts. Result: I fixed it in four days and wrote a short internal note for the next new joiner.
40

What do auto and decltype do?

Save to ▾
Show answer
auto deduces a variable's type from its initialiser, so auto it = m.begin(); avoids long iterator types. It drops top-level const and references unless you write const auto& or auto&. decltype(expr) yields the declared type of an expression without evaluating it, useful in generic code and return types. decltype(auto) keeps reference-ness exactly, which matters when forwarding return values.
41

What are lambdas and how do capture modes work?

Save to ▾
Show answer
A lambda is an unnamed function object written inline, for example [](int a, int b) { return a < b; }. The capture list decides what outside variables it can use: [x] copies x, [&x] references x, [=] copies everything used, [&] references everything used, and [this] captures the object pointer. C++14 allows init captures such as [p = std::move(ptr)]. Reference captures dangle if the lambda outlives the variables.
42

Why use nullptr instead of NULL or 0?

Save to ▾
Show answer
NULL is usually defined as 0 or 0L, an integer, so overloaded functions such as f(int) and f(char*) pick the int version for f(NULL), which surprises readers. nullptr has its own type, std::nullptr_t, that converts only to pointer types, so f(nullptr) calls the pointer overload. It also works correctly in templates where the type is deduced. Modern code should always use nullptr.
43

What are structured bindings and how do they work with range-based for loops?

Save to ▾
Show answer
Structured bindings, from C++17, unpack a pair, tuple, array or simple struct into named variables: auto [id, name] = getUser();. In loops they make map iteration readable: for (const auto& [key, value] : m). The variables are aliases into a hidden object, so const auto& avoids copies. They pair well with if statements with initialisers, such as if (auto [it, ok] = s.insert(x); ok).
44

Use lambdas with standard algorithms to sort strings by length and count those longer than a limit.

Save to ▾
Show answer
#include <algorithm> #include <string> #include <vector> std::vector<std::string> names = {"Ravi", "Anjali", "Om", "Priyanka"}; std::size_t limit = 4; std::sort(names.begin(), names.end(), [](const std::string& a, const std::string& b) { return a.size() < b.size(); }); auto longCount = std::count_if(names.begin(), names.end(), [limit](const std::string& s) { return s.size() > limit; }); // names: Om, Ravi, Anjali, Priyanka; longCount == 2
45

Write a lookup function that uses std::optional instead of returning -1 or a null pointer.

Save to ▾
Show answer
#include <optional> #include <string> #include <unordered_map> std::optional<int> findAge(const std::unordered_map<std::string, int>& db, const std::string& name) { if (auto it = db.find(name); it != db.end()) return it->second; return std::nullopt; } // caller if (auto age = findAge(db, "Meera")) { use(*age); } int a = findAge(db, "Unknown").value_or(0);
46

Show how std::format and std::print format output in modern C++.

Save to ▾
Show answer
#include <format> #include <print> // C++23 #include <string> std::string name = "Kiran"; double score = 92.456; std::string line = std::format("{} scored {:.1f}%", name, score); // C++20 std::print("{:<10}|{:>8.2f}\n", name, score); // C++23 std::string hex = std::format("{:#x}", 255); // 0xff // Type-safe like iostreams, readable like printf, and checked at compile time.
47

What is the difference between a process and a thread?

Save to ▾
Show answer
A process is an independent program with its own address space, file handles and resources; processes are isolated and communicate through IPC such as pipes, sockets or shared memory. Threads live inside a process and share its memory and handles, but each has its own stack and registers. Threads are cheaper to create and communicate faster, but shared memory needs synchronisation to avoid races.
48

How do you create a thread in C++ and what is the difference between join and detach?

Save to ▾
Show answer
std::thread t(func, args); starts a new thread running func. join() blocks until the thread finishes, so the caller can safely use its results. detach() lets the thread run independently; you lose the handle and it must not touch objects that may be destroyed. If a joinable std::thread is destroyed without join or detach, std::terminate is called. C++20 std::jthread joins automatically in its destructor.
49

What are race conditions and data races?

Save to ▾
Show answer
A data race occurs when two threads access the same memory at the same time, at least one writes, and there is no synchronisation; in C++ this is undefined behaviour. A race condition is a broader logic bug where the result depends on timing, such as check-then-act on a file or a balance, even if each access is atomic. Mutexes, atomics and careful design of shared state prevent both.
50

Four threads each increment a shared int one million times, but the final total is less than four million. Why?

Save to ▾
Show answer
counter++ is a read-modify-write of three steps, so threads interleave and overwrite each other's updates, which is a data race and undefined behaviour. Fix it with std::atomic<int> and fetch_add, which is fast for a simple counter, or protect the variable with a mutex. Even better for performance, let each thread count in a local variable and add it to the total once at the end.
51

Write a thread-safe counter using std::atomic.

Save to ▾
Show answer
#include <atomic> #include <iostream> #include <thread> #include <vector> int main() { std::atomic<long> hits{0}; std::vector<std::thread> ts; for (int t = 0; t < 4; ++t) ts.emplace_back([&] { for (int i = 0; i < 1000000; ++i) hits.fetch_add(1, std::memory_order_relaxed); }); for (auto& t : ts) t.join(); std::cout << hits.load() << '\n'; // always 4000000 }
52

Describe how you handled an urgent production issue while on call.

Save to ▾
Show answer
Situation: at 2 AM our order service started timing out. Task: restore service quickly and find the cause. Action: I followed the runbook, checked dashboards, saw thread pool saturation after a new release, rolled back within 15 minutes and posted updates in the incident channel. Next day I found a blocking database call inside a worker thread. Result: service was restored fast, and I added a timeout and an alert on queue depth.
53

Tell me about a time you worked with QA to fix a flaky test.

Save to ▾
Show answer
Situation: a multithreaded integration test failed about once in twenty runs and QA kept reopening the ticket. Task: make it reliable without hiding a real bug. Action: I sat with the QA engineer, ran the test in a loop with logging, and saw it used sleep to wait for a worker. I replaced the sleep with a condition variable signal and fixed a small real race we found. Result: 1000 consecutive passes and better trust between dev and QA.
54

What is CMake and why is it used for C++ projects?

Save to ▾
Show answer
CMake is a cross-platform build system generator. You describe targets, source files, include paths and dependencies in CMakeLists.txt, and CMake generates Makefiles, Ninja files or Visual Studio projects. Modern CMake is target based, using target_link_libraries and target_include_directories so settings flow to dependents. It integrates with package managers such as vcpkg and Conan and with CTest for running tests.
55

What is the difference between a static library and a dynamic library?

Save to ▾
Show answer
A static library, .a or .lib, is copied into the executable at link time, giving a self-contained binary but larger size and a rebuild for every library update. A dynamic library, .so or .dll, is loaded at run time and shared between processes, saving memory and allowing updates without relinking, but it needs the right version present on the machine and has a small call overhead.
56

Which unit testing frameworks are common in C++?

Save to ▾
Show answer
GoogleTest with GoogleMock is the most widely used; it provides TEST and TEST_F macros, assertions such as EXPECT_EQ and ASSERT_TRUE, fixtures and mocking. Catch2 and doctest are lightweight, header-friendly alternatives with natural syntax. Tests are usually registered with CTest in CMake and run in CI on every merge. Good tests are fast, independent and cover edge cases like empty input and overflow.
57

What are header guards and #pragma once?

Save to ▾
Show answer
Including the same header twice in a translation unit would redefine classes and cause errors. Header guards wrap the file in #ifndef MY_HEADER_H, #define MY_HEADER_H and #endif, so the second inclusion is skipped. #pragma once does the same in one line and is supported by all major compilers, though it is not in the standard. Most modern projects use #pragma once for simplicity.
58

Write a minimal modern CMakeLists.txt for an app with a library and tests.

Save to ▾
Show answer
cmake_minimum_required(VERSION 3.20) project(Inventory LANGUAGES CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) add_library(core src/stock.cpp src/order.cpp) target_include_directories(core PUBLIC include) target_compile_options(core PRIVATE -Wall -Wextra -Wpedantic) add_executable(app src/main.cpp) target_link_libraries(app PRIVATE core) enable_testing() find_package(GTest REQUIRED) add_executable(core_tests tests/stock_test.cpp) target_link_libraries(core_tests PRIVATE core GTest::gtest_main) add_test(NAME core_tests COMMAND core_tests)
59

Measure how long a function takes to run in C++.

Save to ▾
Show answer
#include <chrono> #include <iostream> template <typename F> long long timeMs(F&& f) { auto start = std::chrono::steady_clock::now(); f(); auto end = std::chrono::steady_clock::now(); return std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count(); } // usage // auto ms = timeMs([] { heavyWork(); }); // Use steady_clock, not system_clock, because it never jumps backwards.
60

Show the compiler commands to build with strict warnings and sanitizers enabled.

Save to ▾
Show answer
# Strict warnings, treat them as errors g++ -std=c++20 -Wall -Wextra -Wpedantic -Werror -g main.cpp -o app # Address + undefined behaviour sanitizers g++ -std=c++20 -g -O1 -fno-omit-frame-pointer \ -fsanitize=address,undefined main.cpp -o app_asan # Thread sanitizer (separate build) clang++ -std=c++20 -g -O1 -fsanitize=thread main.cpp -o app_tsan # Static analysis clang-tidy main.cpp -- -std=c++20

Frequently asked questions

Who should practise easy C++ questions?

Freshers and career switchers should start here, and experienced candidates should skim them the day before an interview.

How should I practise these?

Answer each question aloud before opening the answer, mark it as solved only when your answer matches the key idea, and save misses to Last-Minute Revision.

Other difficulty levels