Physics Units
What this preview is
Physics Units is a medium quant coding problem on language knowledge in Cpp.
- Difficulty
- Medium
- Topic
- Language Knowledge
- Discipline
- Quant development
- Language
- Cpp
Physics units with dimensional analysis in C++
This medium-difficulty coding problem tests your ability to use C++ operator overloading and the type system to enforce dimensional correctness at compile time. It is representative of the kind of metaprogramming and strong typing that firms value when building robust numerical libraries, especially in quantitative finance and scientific computing.
The core challenge is defining three unit classes — Meters, Seconds, and MetersPerSecond — such that valid physics operations compile and invalid ones do not. This requires careful design of member and non-member operators, forward declarations to resolve circular type dependencies, and attention to both unary and binary operations. Interviewers use this problem to assess whether you understand operator overloading syntax, can reason about type safety, and can write clean, maintainable numerical code.
- Overloading arithmetic operators (
+,-,*,/) for both same-type and cross-type operations - Non-member
friendfunctions for symmetric scalar multiplication - Forward declarations to break circular class dependencies
- Comparison operators within type boundaries
Unlock full access to getcracked
Join to unlock this problem, detailed solutions, and our complete library of quant finance interview prep.