我是否必須將.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