pointers to functions

This is a discussion on pointers to functions within the C Programming forums, part of the General Programming Boards category; all books i've seen so far mention briefly pointers to functions in the advanced section, but i havent seen any ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    32

    pointers to functions

    all books i've seen so far mention briefly pointers to functions in the advanced section, but i havent seen any usefull examples of them that doesnt complecate thins more than doing it the convensional way.

    are they used at all in professional programming? if so, do you know of any links to good examples that i can see?

    thanks

    null

  2. #2
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    They can be used to decide what function is to be used at runtime. If you want to pass a function into a function (eg qsort()) then the function will have to accept an address of a function (a function pointer).

    They are used in 'callback' routines where you pass an address of a function so that it can be called when an event happens (so that the event may be handled differently depending on the function used).
    zen

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    32

    Thumbs up

    hi zen. thanx for the info. i'm looking into it now...

    found a cool link if anyone cares:

    http://www.newty.de/CCPP/FPT/em_fpt.html

    or

    http://www.function-pointer.org/

    regards

    null

  4. #4
    Unregistered
    Guest

    virtual functions

    It is also the way that virtual functions are implemented in C++. This goes along with what somebody else said about choosing which function is executed at runtime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Conversion of pointers to functions
    By hzmonte in forum C Programming
    Replies: 0
    Last Post: 01-20-2009, 01:56 AM
  2. HELP WITH FUNCTIONS and POINTERS!!!
    By cjohnson412 in forum C++ Programming
    Replies: 4
    Last Post: 08-11-2008, 11:48 PM
  3. Replies: 4
    Last Post: 11-23-2003, 07:15 AM
  4. pointers, functions, parameters
    By sballew in forum C Programming
    Replies: 3
    Last Post: 11-11-2001, 10:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21