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 7792915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:19:20+00:00 2026-06-01T22:19:20+00:00

Pointers can be declared as pointing to mutable (non-const) data or pointer to constant

  • 0

Pointers can be declared as pointing to mutable (non-const) data or pointer to constant data.
Pointers can be defined to point to a function.

My coworkers and I were discussing the use of “const” with pointers and the question came up regarding the use of const with function pointers.

Here are some questions:

  1. What is the meaning of a pointer to a constant function versus a
    pointer to a non-constant function?
  2. Can a function be const?
  3. Can a function be non-const (mutable)?
  4. What is the proper (safe) syntax for passing a function pointer?

Edit 1: Function pointer syntax

typedef void (*Function_Pointer)(void); // Pointer to void function returning void.

void function_a(Function_Pointer p_func); // Example 1.
void function_b(const Function_Pointer p_func); // Example 2.
void function_c(Function_Pointer const p_func); // Example 3.
void function_d(const Function_Pointer const p_func); // Example 4.

The above declarations are examples of treating a function pointer like a pointer to an intrinsic type.

A data, variable or memory pointer allows for the above combinations.
So the questions are: can a function pointer have the same combinations and what is meant by a pointer to a const function (such as Example 2)?

  • 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-01T22:19:22+00:00Added an answer on June 1, 2026 at 10:19 pm

    In C, there’s no such thing as a function being const or otherwise, so a pointer to a const function is meaningless (shouldn’t compile, though I haven’t checked with any particular compiler).

    Note that although it’s different, you can have a const pointer to a function, a pointer to function returning const, etc. Essentially everything but the function itself can be const. Consider a few examples:

    // normal pointer to function
    int (*func)(int);
    
    // pointer to const function -- not allowed
    int (const *func)(int);
    
    // const pointer to function. Allowed, must be initialized.          
    int (*const func)(int) = some_func;
    
    // Bonus: pointer to function returning pointer to const
    void const *(*func)(int);
    
    // triple bonus: const pointer to function returning pointer to const.
    void const *(*const func)(int) = func.
    

    As far as passing a pointer to a function as a parameter goes, it’s pretty simple. You normally want to just pass a pointer to the correct type. However, a pointer to any type of function can be converted to a pointer to some other type of function, then back to its original type, and retain the original value.

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

Sidebar

Related Questions

Is it possible to declare a function pointer (non C++ 11) that can point
What's wrong with TextLayoutTransition? Can function pointers not be declared virtual? LCDWrapper.h:23: error: function
I can create function pointers in Fortran 90, with code like real, external ::
I need an array to hold member-function-pointers of different classes. How can I define
If we can use pointers and malloc to create and use arrays, why does
Can c++ create array of pointers to different classes dynamically loaded from dll? ps.without
Can I get the value of MotionEvent.getRawX()/getRawY() of other pointers ? MotionEvent.getRawX() api reference
I'm hoping you can give me some pointers... For some reason when I try
I do not understand pointers. Where can I learn more about them?
I have a query with regards to pointers, can someone help explain the following

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.