Hello,
I'm trying to have a STL set of pointer-to-member-functions in my class. I already know how to declare and define pointers-to-functions and use them with an ordinary array, but using the STL containers has proven problematic.
It kind of works with vectors if I choose to use .push_back(), but .insert() gives me errors. That said, I need to use set. So can anyone tell me how to fix this sample code?
Code:
#include <iostream>
#include <set>
using namespace std;
class test{
public:
test(){ p.insert( &test::g ); }
int f(){ cout << " f() " << endl; }
int g(){ cout << " g() " << endl; }
int h(){ cout << " h() " << endl; }
set< int(test::*)() > p;
};
int main(int argc, char *argv[]){
test a_test;
((a_test).*(a_test.begin()))();
}
Thanks