|
From: Alvin T. <al...@th...> - 2004-07-06 15:24:03
|
if you're using c++ you may want to use virtual functions/polymorphism
instead of using function pointers...
-alvin
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
--
Alvin Thompson
Navy: 34
Army: 6
|