Skip to content

Last updated:2026-10-12

C++ Header-Only vs Implementation Separation

I have recently seen some friends ask a few rather interesting questions, so here is a round-up. These are questions that have come up in real interviews — see how many you know and test your fundamentals.

Interview question 1: What style do you usually write code in? Header-only? Or declaration separated from implementation?

Interview question 2: In C++, can every function have its implementation separated from its declaration? Why?

Interview question 3: What methods exist for separating a template's declaration from its implementation? Please illustrate the pros and cons of each with examples, along with their applicable scenarios?

Comments