Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ lol

Name: Anonymous 2011-03-29 20:53

so how does one store a pointer to a member function and the object from which to call that function, and then call said function from said object?

example:

struct test {
 /*generic function object*/ fun_ptr;
 some_object* object_instance;
} this_test;

some_object new_obj;
this_test.fun_ptr = &some_object::some_function;
this_test.object_instance = &new_obj;

this_test.object_instance->this_test.fun_ptr(/*arguments*/);

???

Name: Anonymous 2011-03-29 21:43

std::function from tr1 or c++0x can be constructed with a member function pointer. The object isnt bound to it though, you need to pass it in as the first argument when invoking it. GCC, Msvc++, and other c++ compilers support it. Google for documentation.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List