我想知道是否可以转发声明在另一个类范围内定义的枚举.例如,请考虑以下事项:
//A.h
class A
{
public:
enum class type: unsigned long { /*some stuff*/ }
};
Run Code Online (Sandbox Code Playgroud)
现在,在另一个标题中,我想转发声明'type'枚举(假设下面的B类有一个用A :: type做某事的函数)
//B.h
enum A::type; //use of undefined type 'A'
class B
{
public:
UseTypeEnum(A::Type&);
};
Run Code Online (Sandbox Code Playgroud)
这也不起作用:
//B.h
class A;
enum A::type; //still use of undefined type
class B...
Run Code Online (Sandbox Code Playgroud)
如果在Ah中将枚举声明为全局范围,则没有问题
有没有办法做到这一点?
| 归档时间: |
|
| 查看次数: |
5461 次 |
| 最近记录: |