【发布时间】:2015-06-12 08:39:48
【问题描述】:
我已经看到了类似的答案,但我似乎无法仅通过查看这些答案来解决我的问题(例如 this 或 that 之一)。
所以,我有那个。
啊.h
#ifndef INCLUDE_CLASS_NAME
#define INCLUDE_CLASS_NAME
#include <B.h>
using namespace C;
D::DPtr myvariable; <-- Error in here
#endif
在包含 B.h 我有这个:
namespace C{
namespace E{
class D
{
public:
typedef shared_ptr<D> DPtr;
}
} //end of namespace E
} // end of namespace C
为什么我在上述行中收到此错误:
'D' does not name a type
我包括定义类的 .h 文件。我错过了什么?
【问题讨论】:
-
为什么将
myvariable声明为mutable?此概念仅适用于班级成员。 -
@Mikhail 是的,改变了这一点,我之前无法编译。
标签: c++