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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:45:09+00:00 2026-06-14T21:45:09+00:00

I have a solution with many projects. I would like to make a class

  • 0

I have a solution with many projects.
I would like to make a class inside common project that receive array and pointer to function.
This class is a member in other projects on that solution. each project class can hold it as member.

On the constructor of the class inside common, How do i pass the pointer of the function ? how do i set a member inside the common class that holds the location of the function i would like to invoke later on ?

My goal is that i can invoke the function using the pointer – while im in the code of the class that is found in the common project..

Thanks

  • 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-14T21:45:11+00:00Added an answer on June 14, 2026 at 9:45 pm

    On the constructor of the class inside common, How do i pass the
    pointer of the function ? how do i set a member inside the common
    class that holds the location of the function i would like to invoke
    later on ?

    typedef void(*FUNCPTR)(int);
    

    This defines my function pointer type, but it also restricts the function to the signature below (retuens void and takes 1 int param) you need to define this for your function signature.

    void myFunction( int someParam )
    {
        //DoSomething with someParam
    }
    
    
    class Foo
    {
    private:
        FUNCPTR mFunction; //Holds pointer
    
    public:
        Foo( FUNCPTR function) : mFunction(function) {} //Initialise instance
    
        void callFunc() {mFunction(1);} //call function
    };
    
    int main(unsigned int argc, const char** argv)
    {
        Foo myFoo(myFunction);
    
        myFoo.callFunc();
    }
    

    In C++ you might well be better however thinking about using function objects in which you create an object and define an operator() which takes the correct parameters and return type but would allow you all the flexibility of objects and polymorphism….

    See C++ Functors – and their uses for some discussion and detail

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

Sidebar

Related Questions

I have a solution which has many projects inside it. I build the solution
We have a large solution with many projects in it, and throughout the project
I have a solution with many many projects, I did not write this project
I have a solution with many projects. In Visual Studio 2010, clicking properties for
I have a legacy project in my solution without comments and many warnings. I
I have a solution in C:\full path here\VS2010\blender.sln This solution contains many projects(around 100).
I have many different projects within a solution. I am in the process of
My situation is this. I have multiple projects under a WPF solution which make
I seem to have looked through many solution on here and the web and
Currently I have solution A that contains a domain layer base and solution B

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.