通过函数指针调用函数时出错(错误C2064)
Error (error C2064) while calling function through function pointer
我收到的确切错误是:
error C2064: term does not evaluate to a function taking 0 arguments
我正在尝试创建一个基本的逻辑门模拟工具。这只是基本逻辑的一部分,这是我的第一个这样规模的项目。我在下面包含的是一个门类的代码,一个AND门类将继承这个基类的属性。我的错误发生在函数指针调用处。
class gate
{
protected:
short int A,B;//These variables represent the two inputs to the Gate.
public:
short int R;//This variable stores the result of the Gate
gate *input_1, *input_2;//Pointers to Inputs
void (gate::*operationPtr)();
void doAND()//Does AND operation
{
R=A&&B;
operationPtr=&gate::doAND;
}
short int getResult()
{
operationPtr();//ERROR OCCURS HERE
return R;
}
};
operationPtr
是指向成员函数的指针,不是指向函数的指针这意味着要取消对它的引用,还必须提供一个调用函数的对象。你可能是这个意思:
short int getResult()
{
(this->*operationPtr)();
return R;
}
相关文章:
- "error: no matching function for call to"构造函数错误
- 为什么类中的ostringstream类型的成员会导致";调用隐含删除复制构造函数";错误
- 尝试将unique_ptrs推送到向量时使用纯虚拟函数错误
- C++ OpenCV 卡尔曼滤波器构造函数错误
- C++:用户定义的显式类型转换函数错误
- C++ 合并字符串以'system'函数错误
- C++ wmain 函数错误时使用 Unicode
- 结构数组的构造函数错误,错误消息:没有构造函数实例与参数列表匹配
- C++ 中常量属性的初始化构造函数错误
- 线程 std::调用未知类型,无法专门化函数错误
- 表单显示对话框函数错误,并且不执行下面的语句
- 函数错误 C2059:语法错误:'>'不起作用
- STL向量上出现奇怪的复制构造函数错误
- C++ Visual Studio 重载函数错误:没有重载函数的实例与指定的类型匹配
- C++引用已删除函数错误
- 为什么通过带有文字编号的引用调用会出现"无匹配函数"错误?
- C++ 乘法定义的构造函数错误消息似乎错误
- 在 c++ 代码中将数组传递给函数错误
- FFMPEG avcodec_decode_video2函数错误代码
- 为什么我会收到转换函数错误