我的问题是关于从A类传递一个成员函数,在B类的成员函数:如何将成员函数传递给另一个成员函数?
我想是这样的:
typedef void (moteurGraphique::* f)(Sprite);
f draw =&moteurGraphique::drawSprite;
defaultScene.boucle(draw);
moteurGraphique
是A类,moteurGraphique::drawSprite
是成员功能,
defaultScene
是B类的一个实例,而boucle
是B成员函数。
所有被称为A的成员函数:
void moteurGraphique::drawMyThings()
我尝试不同的方法来做到这一点,一个在我看来,更合乎逻辑,但它不会工作! 我:
Run-Time Check Failure #3 - The variable 'f' is being used without being initialized.
我认为我做错了什么,有人可以解释我的错误?
什么编译您使用其运行时检查这样的事情? – leemes
你需要发布实际的代码,而不是“这样的事情”。 – molbdnilo
建议:请记住,成员函数绑定到对象。 – 101010