C++ 成员函数原型与非成员函数原型定义的差异
我说的对吗,什么C++ 成员函数原型与非成员函数原型定义的差异,c++,C++,我说的对吗,什么 typedef void(类名::*FunctionName)()是类成员函数原型的定义 及 typedef void(*FunctionName)()是非类或静态函数原型的定义 并且应该以不同的方式使用: 对于类函数 传递:RegisterFunction(&ClassName::function) 用法:(ClassPointer->*(ClassPointer->functionPointer))() 对于静态函数 通过:RegisterFunction(&functio
typedef void(类名::*FunctionName)()
是类成员函数原型的定义
及
typedef void(*FunctionName)()
是非类或静态函数原型的定义
并且应该以不同的方式使用:
对于类函数
传递:RegisterFunction(&ClassName::function)代码>
用法:(ClassPointer->*(ClassPointer->functionPointer))()
对于静态函数
通过:RegisterFunction(&function)代码>
使用:functionPointer()代码>
或者我误解了什么?函数的定义都不是;它们都是类型别名的定义。对不起,我是这个意思。谢谢更新的(ClassPointer->*(ClassPointer->functionPointer))()
应该是(ClassPointer->*functionPointer)(
,如果functionPointer
不是该类的成员。确定。谢谢但在我的情况下,它是一个成员。是否正确?您是否需要在类中使用typedef
,只需要使用指向成员数据和成员函数的指针?