我是否必须将.cpp中的代码放在相应的.h的命名空间中,或者仅仅使用声明来编写代码就足够了?它应该在名称空间吗?
//file .h
namespace a
{
/*interface*/
class my
{
};
}
//file .cpp
using a::my; // Can I just write in this file this declaration and
// after that start to write implementation, or
// should I write:
namespace a //everything in a namespace now
{
//Implementation goes here
}
谢谢。
+1。名称空间中的内容在'namespace {}'中。像这样的东西不要求缩进,所以没有任何问题。 – Potatoswatter 2010-04-11 14:06:54