A
Anonymoose
Hello,
Hope someone can tell me how to do this - I'm an old 'C' hack so
sometimes I get stuck in old-think...this is one of those times...
I've got a bunch of methods in a class that I want to be able to
lookup and call from an array. In 'c' I'd just do something like:
struct thingie {
char *name;
void (*ptrtofunc)();
} listofthingies[] = {
{ "func1", func1 },
{ "func2", func2 }
};
where func1 and func1 are functions that return void that I would usually
call via something like (for example):
(listofthingies[0].func1)();
Here, the equivalent I have is (abbreviated):
struct functable {
CString name;
void (CMyApp::*wscfunc)();
} functable [] = {
{ "send", &CMyApp::func1 },
{ "wsasend", &CMyApp::func2 },
};
But,
(functable[0].wscfunc)();
just results in "term does not evaluate to a function". None of my
reference books help, in this specific case.
So, two questions here: 1. What is the quick way to resolve this (ie: can
I reference my methods this way?), and 2. What is the better C++ way to
accomplish the same thing?
Hope someone can tell me how to do this - I'm an old 'C' hack so
sometimes I get stuck in old-think...this is one of those times...
I've got a bunch of methods in a class that I want to be able to
lookup and call from an array. In 'c' I'd just do something like:
struct thingie {
char *name;
void (*ptrtofunc)();
} listofthingies[] = {
{ "func1", func1 },
{ "func2", func2 }
};
where func1 and func1 are functions that return void that I would usually
call via something like (for example):
(listofthingies[0].func1)();
Here, the equivalent I have is (abbreviated):
struct functable {
CString name;
void (CMyApp::*wscfunc)();
} functable [] = {
{ "send", &CMyApp::func1 },
{ "wsasend", &CMyApp::func2 },
};
But,
(functable[0].wscfunc)();
just results in "term does not evaluate to a function". None of my
reference books help, in this specific case.
So, two questions here: 1. What is the quick way to resolve this (ie: can
I reference my methods this way?), and 2. What is the better C++ way to
accomplish the same thing?