calling a function via a pointer-to-function

Discussion in 'C++' started by NoWonder, Apr 9, 2005.

  1. NoWonder

    NoWonder Guest

    WHO can tell me how can i the structural things about calling a function
    via a pointer-to-function?
    thank you.
     
    NoWonder, Apr 9, 2005
    #1
    1. Advertising

  2. NoWonder wrote:
    > WHO can tell me how can i the structural things about calling a function
    > via a pointer-to-function?
    > thank you.
    >
    >


    Just like any other function:

    void foo( void (*f)() )
    {
    f();
    }

    --
    Matthias Kaeppler
     
    Matthias Kaeppler, Apr 9, 2005
    #2
    1. Advertising

  3. Matthias Kaeppler wrote:
    > Just like any other function:
    >
    > void foo( void (*f)() )
    > {
    > f();
    > }
    >


    Or even more human readable:

    void foo( void f() )
    {
    f();
    }

    I think this is the same, but more intuitive to read. Does someone know
    if this is a historical thing? Maybe the latter is only allowed in C++,
    while the former is allowed in C as well as C++?

    --
    Matthias Kaeppler
     
    Matthias Kaeppler, Apr 9, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    10
    Views:
    731
    Chris Torek
    Feb 4, 2005
  2. jimjim
    Replies:
    16
    Views:
    861
    Jordan Abel
    Mar 28, 2006
  3. Felix Kater
    Replies:
    11
    Views:
    499
    Martin Golding
    Jan 12, 2007
  4. viza
    Replies:
    4
    Views:
    475
    Ben Bacarisse
    Oct 28, 2008
  5. Grigory Petrov
    Replies:
    4
    Views:
    1,278
Loading...

Share This Page