错误 C2064:术语不计算为采用 0 个参数的函数

发布于 2024-09-29 13:16:32 字数 247 浏览 4 评论 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

强者自强 2024-10-06 13:16:33

您将 rs_opCode 定义为方法指针,但将其用作函数指针。

You defined rs_opCode to be a method pointer but you are using it as function pointer.

蓝天白云 2024-10-06 13:16:32

您必须使用方法指针调用的语法,但您需要一个进行实际调用的对象。请注意,typedef 表明您正在定义指向 rsInterpreter 类型的对象方法的指针,因此您需要该类型的对象:

rsInterpreter r;
(r.*rs_opCodes[cur_block])();

但是,这整个想法对我来说没有多大意义。您正在编写要在对象中调用的方法指针数组...乍一看,我无法想到此类代码的可用示例...

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:

rsInterpreter r;
(r.*rs_opCodes[cur_block])();

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...

往事风中埋 2024-10-06 13:16:32

您将 rs_opCode 定义为指向成员函数(属于 rsInterpreter 类)的指针。
要调用这样的野兽,你需要语法

(object.*rs_opCodes[cur_block])();

(pointer->*rs_opCodes[curr_block])();

You defined rs_opCode as a pointer to a member function (of class rsInterpreter).
To call such a beast, you need the sytax

(object.*rs_opCodes[cur_block])();

or

(pointer->*rs_opCodes[curr_block])();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文