可能重複:
Is it a good idea to wrap an #include in a namespace block?我們應該將#include放入命名空間嗎?
// Method One
#ifndef XXX_H
#define XXX_H
#include <iostream>
#include "myhead.h"
namespace XXX
{
/...
}
#endif
OR
// Method Two
namespace XXX
{
#ifndef XXX_H
#define XXX_H
#include <iostream>
#include "myhead.h"
/...
#endif
}
當我們定義一個新的namespace XXX
,我們應該將#include directive
內部命名空間或沒有?
謝謝
http://stackoverflow.com/a/2868971/76173 – thorn 2012-03-29 16:01:07