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

  • Home
  • SEARCH
  • 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 8906487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:40:08+00:00 2026-06-15T02:40:08+00:00

Given the following two typedef s: typedef void (*pftype)(int); typedef void ftype(int); I understand

  • 0

Given the following two typedefs:

typedef void (*pftype)(int);

typedef void ftype(int);

I understand that the first defines pftype as a pointer to a function that takes one int parameter and returns nothing, and the second defines ftype as a function type that takes one int parameter and returns nothing. I do not, however, understand what the second might be used for.

I can create a function that matches these types:

void thefunc(int arg)
{
    cout << "called with " << arg << endl;
}

and then I can create pointers to this function using each:

int main(int argc, char* argv[])
{
    pftype pointer_one = thefunc;
    ftype *pointer_two = thefunc;

    pointer_one(1);
    pointer_two(2);
}

When using the function type, I have to specify that I’m creating a pointer. Using the function pointer type, I do not. Either can be used interchangeably as a parameter type:

void run_a_thing_1(ftype pf)
{
    pf(11);
}

void run_a_thing_2(pftype pf)
{
    pf(12);
}

What use, therefore, is the function type? Doesn’t the function pointer type cover the cases, and do it more conveniently?

  • 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-15T02:40:09+00:00Added an answer on June 15, 2026 at 2:40 am

    As well as the use you point out (the underlying type of a pointer or reference to a function), the most common uses for function types are in function declarations:

    void f(); // declares a function f, of type void()
    

    for which one might want to use a typedef:

    typedef void ft(some, complicated, signature);
    ft f;
    ft g;
    
    // Although the typedef can't be used for definitions:
    void f(some, complicated, signature) {...}
    

    and as template parameters:

    std::function<void()> fn = f;  // uses a function type to specify the signature
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following two objects: function newDoodle() { var Doodle = { /* Variables
Given the following HTML example... <div id='div1'>div one</div> <div id='div2'>div two</div> ...I found that
Given the following two classes: public class ABC { public void Accept(Ordering<User> xyz) {
I have the following two boost::fusion maps. namespace bf = boost::fusion; typedef bf::map<bf::pair<char,float>,bf::pair<int,double>> FusionMap;
Given the following two tables: Person table id (pk) first middle last age Address
I have the following code: /* * Pointer to a function that reads a
Given the following two: Scenario 1 function inner() { // a bunch of code
I'm trying to write a program that does the following: Given two intervals A
Given the following two defined routes: routes.MapRoute(name: CityCategoryPage, url: {city}-{state}/{categoryName}/__c/, defaults: new { controller
Given the following two constructor signatures, should it be possible to construct a Couple

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.