错误 C2064:术语不计算为采用 0 个参数的函数
在我编写的某些代码中,我有以下行,这给了我错误 C2064:
rs_opCodes[cur_block]();
rs_opCodes 定义如下:
typedef void (rsInterpreter::*rs_opCode)();
rs_opCode rs_opCodes[NUM_OPCODES];
有谁知道为什么我收到错误 C2064?
In some code I'm writing, I have the following line, which gives me error C2064:
rs_opCodes[cur_block]();
rs_opCodes is defined as such:
typedef void (rsInterpreter::*rs_opCode)();
rs_opCode rs_opCodes[NUM_OPCODES];
Does anyone know why I'm recieved error C2064?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您将 rs_opCode 定义为方法指针,但将其用作函数指针。
You defined
rs_opCode
to be a method pointer but you are using it as function pointer.您必须使用方法指针调用的语法,但您需要一个进行实际调用的对象。请注意,typedef 表明您正在定义指向 rsInterpreter 类型的对象方法的指针,因此您需要该类型的对象:
但是,这整个想法对我来说没有多大意义。您正在编写要在对象中调用的方法指针数组...乍一看,我无法想到此类代码的可用示例...
You have to use the syntax of method pointer call, but you need an object to which make the actual call. Note that the typedef stablishes that you're defining pointers to a method of objects of type rsInterpreter, so you need an object of that type:
However, the whole idea of this doesn't make much sense to me. You're writting an array of method pointers to be called in objects... I can't, at first thought, come up out of my mind of an usable example of this type of code...
您将 rs_opCode 定义为指向成员函数(属于 rsInterpreter 类)的指针。
要调用这样的野兽,你需要语法
或
You defined
rs_opCode
as a pointer to a member function (of classrsInterpreter
).To call such a beast, you need the sytax
or