Hiding a C++ class in a header without using the unnamed namespace

后端 未结 7 1721
走了就别回头了
走了就别回头了 2020-12-19 12:50

I am writing a C++ header in which I define a

class A {
   // ...
};

that I would like to hide from the outside world (because it may chang

相关标签:
7条回答
  • 2020-12-19 13:17

    The right way to go about it in C++ is PIMPL idiom. Alternative solution is to put the class you want to hide into a nested namespace, which is usually called detail. But that will not make it totally private as users will still be exposed to its dependencies, and will be able to use it directly.

    0 讨论(0)
提交回复
热议问题