Files
CPlusPlusThings/site_extras/cpp-idioms-header-only-vs-implementation.md
light-city dfe1c933b3 docs: address community issue feedback (#5 #338 #142 #246 #136 #303)
- const README: rewrite the space-saving claim per issue #5 follow-ups
  (constant-expression const vs #define immediates; which const qualify
  as constant expressions)
- const README: fix the class-section diagnosis per issue #338 (overload
  resolution picks the const overload; the restriction only surfaces
  once that overload is removed)
- sizeof README: virtual-inheritance result is compiler-dependent
  (GCC merges vbptr+vfptr -> 16, MSVC keeps them separate -> 32) #246
- static README: new section on internal linkage / access restriction
  with anonymous-namespace comparison #142
- 10-day practice: full problem list table + fixed day links #136
- new design_pattern/singleton/singleton_default.hpp: reusable
  thread-safe CRTP singleton template, compile+concurrency tested #303
2026-10-13 19:23:54 +08:00

696 B
Raw Permalink Blame History

来自 C++那些事网站 的文章,由站点同步脚本导出。

C++ Header-Only 与实现分离

最近看到一些小伙伴问到了几个比较有趣的问题,这里总结一下,这些都是实际面试中出现过的问题,看看你知道多少,考察一下底子。

面试问题1:你通常编写代码的风格是什么?Header-Only?还是声明与实现分离?

面试问题2:C++里面是否所有的函数可以分离实现与声明?为什么?

面试问题3:模版的声明与实现分离有哪些方法?请举例说明各自优缺点,适用场景?