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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:16:46+00:00 2026-05-25T18:16:46+00:00

I am trying to make a vector hold void pointers to functions, which will

  • 0

I am trying to make a vector hold void pointers to functions, which will later be called secuentially.
So, lets say that I have got three functions. int a(), void b();, bool c();

My vector is vector<void *> vec;

And my function that stores pointers to functions.

void registerFunction(void *func)
{
    vec.push_back(func);
}

Now my problem is when trying to call all the functions stored, since they are all void pointers, I just cannot call the functions without knowing their type.

So my question is… is there any way to store types of symbols so I can relate them to their respective pointers and then typecast when calling a void pointer to a function?

Note: Functions won’t be always be of type, for example, void (*)(), I will want to add methods also, hence ie. void (someclass::)(). Is it asking for too much? Should it work?

  • 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-25T18:16:46+00:00Added an answer on May 25, 2026 at 6:16 pm

    void* can’t safely be used as a generic pointer-to-function type (though you might be able to get away with it).

    But any function-to-pointer value can be converted to another pointer-to-function type and back again without loss of information. So you can use, for example, void (*)() (pointer to function returning void and taking no arguments) as a generic pointer-to-function type.

    As for storing the type, I’m not sure that’s possible. If there are only a limited number of possibilities, you can use an enumeration type and a switch statement.

    But you’ll probably be better off using a design based on inheritance.

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

Sidebar

Related Questions

I'm trying to make a vector drawing application using OpenGL which will allow the
trying to make a page which will recursively call a function until a limit
Im trying to make a function that will return an element of type point:
Currently, I'm trying to make a function that sorts a vector full of fighters
I'm trying to make a grammar in Boost.Proto that matches a vector type, but
I am trying to make a vector extended header. One of the functions sets
I’m trying to make something that will take lines of input from the user,
I've been trying to make an ncurses program that will end the ncurses mode
Trying to make a make generic select control that I can dynamically add elements
Trying to make a custom :confirm message for a rails form that returns data

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.