可能重复:
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