Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8113431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:49:44+00:00 2026-06-06T02:49:44+00:00

I am so confused with this code in the book : typedef int (*healthCalcFunc)

  • 0

I am so confused with this code in the book :

typedef int (*healthCalcFunc) (const GameCharacter&)

and I understand that
typedef double* PDouble, means the word PDouble can be used to declare a pointer to double.

But I can’t figure out the meaning of typedef int (*healthCalcFunc) (const GameCharacter&)

Is there anyone can help me to explain this?

Thanks in advance

🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:49:46+00:00Added an answer on June 6, 2026 at 2:49 am
    typedef int (*healthCalcFunc) (const GameCharacter&);
    

    It introduces a name called healthCalcFunc for a type which describes a function-pointer, taking one parameter of type const GameCharacter& and returning an int.

    So this means, if you’ve a function as:

    int some_function(const GameCharacter&)
    {
        //...
    }
    

    Then you can create a pointer-object which would point to the above function as:

    healthCalcFunc pfun = some_function;
    

    and then use pfun in place of some_function as:

    some_function(args);  /normal call
    
    pfun(args);  //calling using function pointer 
                 //it is exactly same as the previous call
    

    And benefit with this approach is that you can pass around pfun (or some_function) to other function as:

    void other_function(healthCalcFunc pfun)
    {
        //..
        pfun(args); //invoke the function!
        //..
    }
    
    healthCalcFunc pfun = some_function;
    
    other_function(some_function);  
    other_function(pfun); 
    

    Here other_function will use the function pointer to invoke the function. That way, next time you can pass another function matching the function signature to other_function and other_function will invoke that another function instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

just a bit confused by this code var counter = function() { //... var
I am a little confused by this snippet of code (presented in the CocoaFundamentals
I ran across this chunk of code (modified) in our application, and am confused
This isn't a code question for once, but it definitely has me confused. Basically,
I'm confused about this. Most of us have been told that there isn't any
I am confused by a code listing in a book i am reading, C#
This section has me thoroughly confused. I have an example problem that I am
I am a bit confused here. This is from a great C book, and
From Accelerated C++ (book), I found this code which is identical program, but the
I read this code in a book just now. public class AdapterWrapper implements ListAdapter

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.