C++ Interview Questions for HFT and Quant Developer Roles
The C++ questions low-latency firms actually ask, from move semantics and the memory model to false sharing and lock-free queues, with what a strong answer sounds like.

At most firms, a C++ interview checks whether you can write C++. At a high-frequency trading firm, it checks whether you know what your C++ costs. The question is rarely "implement this". It is "implement this, now tell me where the time goes", followed by "what happens when two threads touch it", followed by "and on which cache line does that counter live?"
That shift catches out strong generalist engineers every hiring season. This guide covers how the loop is structured at low-latency firms, the six families of questions that come up, worked examples with what a strong answer sounds like, and how to prepare. If you are earlier in the journey, start with our C++ roadmap for quant trading and come back.
How the loop is structured
The sequence at prop trading firms and HFT shops such as Hudson River Trading, Jump Trading, Citadel Securities, Tower Research, DRW and Optiver's engineering teams is fairly consistent:
- An online assessment, usually two or three algorithmic problems under time pressure. Standard competitive programming, but expect them to be on the harder side.
- One or two technical phone screens with live coding, often in C++ specifically, and often with follow-up questions about the code you just wrote.
- An onsite or superday mixing algorithms, C++ depth, systems and low-latency design, sometimes a short probability question, and a behavioral conversation.
The C++ depth questions concentrate in stages two and three. They come in six families.
1. Object lifetime and resource management
The foundation. Interviewers check that you understand what the compiler does on your behalf.
- What does
std::movedo? Nothing at runtime. It is a cast to an rvalue reference, which makes the object eligible to be moved from. Whether a move actually happens depends on the overload chosen. A strong answer says that, then mentions that moving fromconstobjects silently copies. - Rule of zero, three and five. When you need to write a destructor, copy and move operations, and why the best answer is usually to need none of them by composing types that already manage their resources.
unique_ptrversusshared_ptr.unique_ptris free: the size of a raw pointer with a default deleter, with no runtime overhead.shared_ptrcosts a separate control block allocation (unless created withmake_shared) and an atomic reference count update on every copy, which is contention on a shared cache line when several threads copy the same pointer. On a hot path that matters.
A favourite follow-up: "Why does std::vector sometimes copy elements during reallocation instead of moving them?" Because vector offers the strong exception guarantee on push_back. If your type's move constructor is not noexcept, a move that throws halfway through reallocation would leave the vector in a broken state, so the library falls back to copying. Mark move constructors noexcept. Candidates who know this signal that they have read library code, not just written application code.
2. Templates and compile-time work
- Virtual dispatch versus CRTP. A virtual call costs an indirect branch through the vtable and usually blocks inlining. The curiously recurring template pattern gives static polymorphism: the call is resolved at compile time and can be inlined. Know when each is the right tool, and say that the cost of a virtual call is mostly the lost inlining and a possible misprediction, not the pointer chase itself.
constexprandconsteval. Moving work to compile time: lookup tables, parsing fixed formats, validating configuration.- Type erasure. How
std::functionworks, why it may allocate, and how small buffer optimisation avoids that for small callables.
3. Memory, caches and data layout
This is where HFT interviews diverge most from general ones.
- Cache lines. Usually 64 bytes on x86. Data you touch together should live together. A struct of 12 hot fields scattered across 3 cache lines costs three misses where one would do.
- Struct padding and member ordering. How alignment inflates
sizeof, and how reordering members recovers it. - Array of structs versus struct of arrays. Which one vectorises, and which one wastes bandwidth when a loop reads one field.
- Container choice.
std::vectorversusstd::list(contiguous memory beats asymptotic insertion cost for almost any realistic size),std::mapversusstd::unordered_mapversus a sorted vector, and why node-based containers hurt cache behaviour. - Allocation on the hot path. Why
mallochas unpredictable latency, and how pools, arenas and preallocation avoid it.
Worked question: what is wrong with this code?
struct Stats {
std::atomic<uint64_t> orders_sent{0}; // written by thread A
std::atomic<uint64_t> fills_received{0}; // written by thread B
};Each counter is only ever written by one thread, so there is no data race. A weak answer stops there. A strong answer spots false sharing: both counters fit on the same 64-byte cache line, so every write by thread A invalidates that line in thread B's core and the other way round. The line ping-pongs between cores and both threads slow down dramatically, even though they never touch each other's data.
The fix is to put each counter on its own line:
struct Stats {
alignas(64) std::atomic<uint64_t> orders_sent{0};
alignas(64) std::atomic<uint64_t> fills_received{0};
};Mention std::hardware_destructive_interference_size as the portable spelling, with the caveat that some compilers warn about using it in ABI-visible types, and you have given the best available answer.
4. Concurrency and the memory model
- What does
memory_order_acquire/releaseguarantee? A release store makes every write before it visible to a thread that performs an acquire load reading that value. That is enough for most producer–consumer handoffs and cheaper than the default sequentially consistent ordering on weakly ordered architectures. - Mutex costs. An uncontended lock is cheap; a contended one can mean a system call and a context switch, which is an eternity at trading timescales. Know when a spinlock is appropriate and when it burns a core for nothing.
- Lock-free structures. The ABA problem, why lock-free does not mean fast, and why a well-designed single-producer single-consumer queue is the workhorse of trading systems.
The SPSC queue is close to a guaranteed question at some firms, either to implement or to critique.
An SPSC ring buffer, step by step
What the interviewer is listening for: a fixed-size power-of-two buffer so the index wraps with a mask instead of a modulo; a head index written only by the consumer and a tail index written only by the producer, each on its own cache line; release stores when publishing and acquire loads when observing; and, for extra credit, each side caching its last view of the other's index so it does not read a contended line on every operation.
5. Latency engineering
Less about the language, more about the machine.
- Branch prediction. Why a predictable branch is nearly free and a mispredicted one costs tens of cycles, and how to restructure hot code to avoid unpredictable branches. Know
[[likely]]and[[unlikely]]and their limits. - Measuring latency. Averages hide everything. Talk about percentiles, the 99th and 99.9th, and why tail latency is what loses trades. Know how to timestamp cheaply.
- Avoiding the kernel. Why system calls are avoided on the hot path, what kernel-bypass networking does, why trading threads busy-poll instead of sleeping, and why they are pinned to isolated cores.
- Warm-up. Why the first pass through code is slow (cold caches, cold branch predictors, page faults), and why systems pre-touch memory and exercise their hot paths before the market opens.
A recommended watch: Carl Cook's CppCon 2017 talk When a Microsecond Is an Eternity: High Performance Trading Systems in C++. Interviewers at several firms have seen it, and its examples are fair game.
6. Trading-domain design
At the onsite, design questions are usually about trading infrastructure:
- Design an order book. Price levels, order lookup by ID, and the trade-off between a tree of price levels and a flat array indexed by price offset, which wins when prices cluster near the touch.
- Handle a market data feed. Decode a binary protocol without copying, detect sequence gaps and recover, and decide what to do when the consumer falls behind (conflation: keep only the latest state per instrument).
- Build a rate limiter or a risk check that runs on every order without adding meaningful latency.
How to prepare
- Write the structures yourself.
unique_ptr,shared_ptrwith weak references, a vector, a small-string-optimised string, an SPSC ring buffer, a memory pool, an order book. You understand a structure only after implementing it and finding the bugs. - Read code for hidden costs. For every snippet you see, ask: where are the allocations, the copies, the virtual calls, the shared cache lines, the unpredictable branches?
- Benchmark what you claim. Measure false sharing yourself once. It is a ten-minute experiment, and afterwards you will explain it from experience rather than from memory.
- Keep your algorithms sharp. The online assessment still filters on standard algorithmic problems, and C++ depth does not help if you never reach the onsite.
- Know the reference books. Scott Meyers' Effective Modern C++ for the language and Anthony Williams' C++ Concurrency in Action for the memory model and lock-free programming.
Practise on PuzzledQuant
Reading about these structures does not prepare you to write them in front of someone. Writing them does. The C++ exercises are 20 problems built around exactly this interview, each with a starter file, tests you can run in the browser, and a submit check:
- Ownership and memory: unique pointer, shared pointer with weak references, a custom vector, small string optimisation, a memory pool allocator, intrusive linked lists.
- Concurrency: a lock-free SPSC queue, a ring buffer, a thread-safe singleton, a thread pool, reader-writer locks.
- Performance and compile time: type erasure, compile-time type lists, cache-friendly Eytzinger binary search, an LRU cache.
- Trading systems: an order book, market data conflation, feed sequence gap detection, and binary wire protocol decoding.
The workspace has a resizable editor, a console with Run and Submit output, and progress tracking, so you can see which exercises you have solved, attempted or only looked at. Some exercises are free to try, and the full set comes with premium. The problem bank also has a C++ topic for shorter conceptual questions, and if you are aiming at Jane Street, the OCaml exercises cover the language they actually use.
Frequently asked questions
What C++ topics do HFT firms ask about?
Object lifetime and move semantics, smart pointers and their costs, templates and static polymorphism, the C++ memory model and atomics, lock-free data structures (especially single-producer single-consumer queues), cache behaviour and false sharing, data layout, allocation on the hot path, branch prediction, and trading-specific design such as order books and market data handlers.
Do I need to know lock-free programming for a quant developer interview?
For low-latency and HFT roles, yes, at least to the level of explaining acquire and release ordering and implementing or critiquing a single-producer single-consumer ring buffer. You are rarely asked to write a general multi-producer lock-free structure from scratch, but you should know why that is hard, including the ABA problem.
What is false sharing and why do interviewers ask about it?
False sharing happens when two threads write to different variables that sit on the same cache line. The cache coherence protocol moves the whole line between cores on every write, so both threads slow down even though they share no data. Interviewers ask because it is invisible in the source code and only visible to someone who thinks about the hardware, which is exactly the instinct HFT firms hire for.
Is the online assessment for HFT developer roles in C++?
Usually you can choose your language for the algorithmic online assessment, though C++ is common and some firms require it for later rounds. The C++-specific depth questions come in the phone screens and the onsite, so the language matters most from the second stage onward.
How should I prepare for a C++ interview at a trading firm?
Implement the core structures yourself (smart pointers, a vector, a ring buffer, a memory pool, an order book), learn the memory model and cache behaviour well enough to explain them and measure them, practise reading code for hidden costs, and keep your algorithm skills sharp for the online assessment. Structured exercises with tests, such as PuzzledQuant's C++ set, make the implementation practice efficient.