c++函数指针的疑惑,哪位大侠给解释一下
template <>struct CameraTraits<Camera>
{
typedef CameraListener TCamListener;
typedef ICamera TCamUser;
typedef ICameraClient TCamCallbacks;
typedef status_t (ICameraService::*TCamConnectService)(const sp<ICameraClient>&,//这个定义一个函数指针
int, const String16&, int,
/*out*/
sp<ICamera>&);
static TCamConnectService fnConnectService;
};
CameraTraits<Camera>::TCamConnectService CameraTraits<Camera>::fnConnectService =//函数指针赋值
&ICameraService::connect;
TCamConnectService fnConnectService = TCamTraits::fnConnectService;
status = (cs.get()->*fnConnectService)(cl, cameraId, clientPackageName, clientUid,//调用函数指针所指向的函数,这块我有点蒙逼了,->*是什么鬼?这个不是个语法错误吗?
/*out*/ c->mCamera);
我所理解的应该是这样:
status = *(cs.get()->fnConnectService)(cl, cameraId, clientPackageName, clientUid,//不应该是这样写吗?
/*out*/ c->mCamera); 大神速来啊 自己顶,没人给解释下吗? 这是C++的类成员函数指针
页:
[1]