作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
有一个问题我看不懂:
Types.hpp:
enum SomeEnum { one, two, three };
First.hpp:
#include "Types.hpp"
class First
{
public: void someFunc(SomeEnum type) { /* ... */ }
};
第二个.hpp:
#include "Types.hpp"
#include "First.hpp"
class Second
{
public: void Foo()
{
First obj;
obj.someFunc(two); // two is from SomeEnum
}
};
你的错误:
no matching function for call to ‘First::someFunc(SomeEnum)’
note: candidate is: void First::someFunc(First::SomeEnum)
最佳答案
我想你刚刚改变了:
no matching function for call to ‘First::someFunc(SomeEnum)’
note: candidate is: void First::someFunc(First::SomeEnum)
这不是吗:
no matching function for call to ‘First::someFunc(SomeEnum)’
note: candidate is: bool First::someFunc(First::SomeEnum)
无论如何,这改变了一切。枚举是在 class First
中声明的吗?如果是这样,或者如果您不知道,只需尝试调用该函数,将 First::
放在枚举前面:
obj.someFunc( First::two ); // two is from SomeEnum
^^^^^^^
关于c++ - 使用枚举,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4009629/
我是一名优秀的程序员,十分优秀!