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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:48:51+00:00 2026-05-13T16:48:51+00:00

Firstly, I’ve got functions like this. void func1(); void func2(); void func3(); Then I

  • 0

Firstly, I’ve got functions like this.

void func1();
void func2();
void func3();

Then I create my typedef for the array:

void (*FP)();

If I write a normal array of function pointers, it should be something like this:

FP array[3] = {&func1, &func2, &func3};

I want to make it a constant array, using const before “FP”, but I’ve got this error messages:

error: cannot convert ‘void ( * )()’ to ‘void ( * const)()’ inialization

PD: Sorry my bad English.

EDIT:

x.h

typedef void (*FP)();

class x
{
 private:
  int number;
  void func1();
  void func2();
  void func3();
  static const FP array[3];
}

x.cpp

const FP x::array[3] = {&x::func1, &x::func2, &x::func3};

My code is more large and complex, this is a summary

  • 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-05-13T16:48:52+00:00Added an answer on May 13, 2026 at 4:48 pm

    Then I create my typedef for the array:
    void (*FP)();

    Did you miss typedef before void?

    Following works on my compiler.

     void func1(){}
     void func2(){}
     void func3(){}
    
     typedef void (*FP)();
    
    
     int main()
     {
         const FP ar[3]= {&func1, &func2, &func3};
     }
    

    EDIT

    (after seeing your edits)

    x.h

     class x;
     typedef void (x::*FP)(); // you made a mistake here
    
     class x
     {
       public:
          void func1();
          void func2();
          void func3();
          static const FP array[3];
     };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Firstly, I wrote my customized setter for an NSString* like this: - (void)setDateString:(NSString *)newDateString
Firstly, this is going to sound like homework, but it ain't. Just a problem
firstly i recently installed this program as I’m working on a project to create
Firstly I have tried to re create this within a JSfiddle but unable to,
Firstly I have a class signature that looks like this: internal class JobStore :
Firstly, this seems like something that should have been asked before, but I cannot
Firstly sorry if this is a common question but I couldn't find anything on
Firstly, I know this [type of] question is frequently asked, so let me preface
Firstly, I'm not using rails. This is vanilla ruby application. I've read about packaging
Firstly, I'd like to show you a piece of code. The code is a

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.