function pointer on classfunctions
-
H@llo I have a class with some memberfunctions and like to refer to these by unsing functionpointers. all my tries ends up in errors some sample here:
// myCom.h class myCom { public: int send(int,char*); int read(int,unsigned int,BYTE*); };
// action.h class myCom; typedef int (*cdout)(int ,char* ); typedef int (*cdread)(int ,unsigned int ,BYTE* ); class action { myCom* mCom; ... };
// action.cpp ... mCom = new myCom; ... cdout test = mCom->send; // error C2440: 'initializing' : cannot convert from '' to 'int (__cdecl *)(int,char *)' or cdout test; test = mCom->send; // error C2440: '=' : cannot convert from 'int (__thiscall CINTERFACE::*)(int,char *)' to 'int (__cdecl *)(int,char *)' ...
:confused: Anyone any idea?? THX -
H@llo I have a class with some memberfunctions and like to refer to these by unsing functionpointers. all my tries ends up in errors some sample here:
// myCom.h class myCom { public: int send(int,char*); int read(int,unsigned int,BYTE*); };
// action.h class myCom; typedef int (*cdout)(int ,char* ); typedef int (*cdread)(int ,unsigned int ,BYTE* ); class action { myCom* mCom; ... };
// action.cpp ... mCom = new myCom; ... cdout test = mCom->send; // error C2440: 'initializing' : cannot convert from '' to 'int (__cdecl *)(int,char *)' or cdout test; test = mCom->send; // error C2440: '=' : cannot convert from 'int (__thiscall CINTERFACE::*)(int,char *)' to 'int (__cdecl *)(int,char *)' ...
:confused: Anyone any idea?? THXyou have
typedef int (*cdout)(int ,char* );
andint send(int,char*);
but send is a member function... its synopsis is not what you wrote. it gets an implicit parameter (this
).send()
actually has 3 parameters. if you want to use it, you must declare it as astatic
function. but if it uses data members of its class, it won't see them anymore. so you'll have to pass a new parameter explicitely to yoursend()
function to allow it accessing the members. You'll also have to change thecdout
declaration... cheers,
TOXCCT >>> GEII power
[toxcct][VisualCalc] -
you have
typedef int (*cdout)(int ,char* );
andint send(int,char*);
but send is a member function... its synopsis is not what you wrote. it gets an implicit parameter (this
).send()
actually has 3 parameters. if you want to use it, you must declare it as astatic
function. but if it uses data members of its class, it won't see them anymore. so you'll have to pass a new parameter explicitely to yoursend()
function to allow it accessing the members. You'll also have to change thecdout
declaration... cheers,
TOXCCT >>> GEII power
[toxcct][VisualCalc]Hallo OK - got it so far. :) But at least i like to send this functionpointer to a created dll. So if
send()
is static i have to change to much code. Changeing thetypedef
restricts the needed parsing possibility for my dll. :doh: I'm sorry, but i'm not very good in c programming. Is there any other fast possibility to call a dll function that communicating with class member functions? :confused: THX -
Hallo OK - got it so far. :) But at least i like to send this functionpointer to a created dll. So if
send()
is static i have to change to much code. Changeing thetypedef
restricts the needed parsing possibility for my dll. :doh: I'm sorry, but i'm not very good in c programming. Is there any other fast possibility to call a dll function that communicating with class member functions? :confused: THX -
H@llo I have a class with some memberfunctions and like to refer to these by unsing functionpointers. all my tries ends up in errors some sample here:
// myCom.h class myCom { public: int send(int,char*); int read(int,unsigned int,BYTE*); };
// action.h class myCom; typedef int (*cdout)(int ,char* ); typedef int (*cdread)(int ,unsigned int ,BYTE* ); class action { myCom* mCom; ... };
// action.cpp ... mCom = new myCom; ... cdout test = mCom->send; // error C2440: 'initializing' : cannot convert from '' to 'int (__cdecl *)(int,char *)' or cdout test; test = mCom->send; // error C2440: '=' : cannot convert from 'int (__thiscall CINTERFACE::*)(int,char *)' to 'int (__cdecl *)(int,char *)' ...
:confused: Anyone any idea?? THXSee Class function callback[^]