+ Reply to Thread
Results 1 to 2 of 2

Thread: What is function pointer and what are is its usage?

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    49

    What is function pointer and what are is its usage?

    Hi All,

    I would like to know about function pointer in C++ and what are is its usage?

    Thanks...

  2. #2
    Senior Member
    Join Date
    Feb 2012
    Posts
    109
    Hi,

    Following is the starting point for function pointer.

    Code:
    void CallMe(const char *pMessage)
    {
    	printf("Hurray, function is invoked. %s", pMessage) ;
    }
    
    typedef void (*PFNCALLME) (const char *) ;
    
    void UseFunctionPointer()
    {
    	PFNCALLME pfnCallMe = NULL ;
    	pfnCallMe = &CallMe ;
    
    	pfnCallMe("I am using function pointer") ;
    }
    Normal use for function pointer is:
    a. Getting function address from a DLL like GetProcAddress(). http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
    b. Register a callback to another component to get notified.

    Thanks.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts