Creating a C++ namespace in header and source (cpp)

前端 未结 8 1593
猫巷女王i
猫巷女王i 2020-12-23 00:22

Is there any difference between wrapping both header and cpp file contents in a namespace or wrapping just the header contents and then doing using namespace

8条回答
  •  悲&欢浪女
    2020-12-23 01:11

    There's no performance penalties, since the resulting could would be the same, but putting your Foo into namespace implicitly introduces ambiguity in case you have Foos in different namespaces. You can get your code fubar, indeed. I'd recommend avoiding using using for this purpose.

    And you have a stray { after using namespace ;-)

提交回复
热议问题