|
From: David M. <dml...@co...> - 2004-07-04 03:22:51
|
int result3 = (instance.*pt2Member)(12, 'a', 'b'); // Outside class int result4 = (*this.*pt2Member)(12, 'a', 'b'); // Inside class in your case it would be: cout << (cA.*pFunc)(); A good tutorial on this topic is avalible @ www.function-pointer.org Hope this Helps David McKen Harry Piterson wrote: > Hello, All!!! > > I need to call function-member of class by its pointer. For example: > > > //- main.h ---------------------------------- > #include <iostream> > #include <stdlib.h> > > class A > { > public: > int f (void) { return 5; } > }; > > //- main.cpp -------------------------------- > #include "main.h" > > using namespace std; > > int main(int argc, char *argv[]) > { > A cA; > > int ( A::*pFunc ) (void); > > pFunc = &A::f; > > // cout << ??? How I can call cA.f() using the pointer pFunc? > > system("PAUSE"); > return 0; > } > > > > ------------------------------------------------------- > This SF.Net email sponsored by Black Hat Briefings & Training. > Attend Black Hat Briefings & Training, Las Vegas July 24-29 - > digital self defense, top technical experts, no vendor pitches, > unmatched networking opportunities. Visit www.blackhat.com > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |