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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:48:21+00:00 2026-06-12T23:48:21+00:00

I have a problem handling a function pointer.I have made a class Control that

  • 0

I have a problem handling a function pointer.I have made a class Control that has a function pointer as member:

void (*mouseFunction) (Control*, Event*);

The member is protected, and it has setter and getter:

void (*getMouseFunction()) (Control*,Event*)
{
    return mouseFunction;
}
void setMouseFunction( void (*mouseFunction) (Control*, Event*) )
{
    this->mouseFunction=mouseFunction;
}

The problem is that even after setting the pointer, it’s always NULL.
I have a function declared inside a header file:

void mouseFunction (Control* control, Event* event)
{
    std::cout << "Inside Text Field";
}

If I try to assign it:

myControlInstance.setMouseFunction(mouseFunction);

If I use the getter to get the pointer it’s NULL; and if I try to execute the function I get EXC_BAD_ACCESS:

error: address doesn't contain a section that points to a section in a object file
  • 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-12T23:48:23+00:00Added an answer on June 12, 2026 at 11:48 pm

    Following cod is working, so be sure that youre method is public to be accessible from other place than object.

    typedef int Event;
    
    class Control
    {
    
    public:
        void (*mouseFunction) (Control*, Event*);
    
        void (*getMouseFunction()) (Control*,Event*)
        {
            return mouseFunction;
        }
    
        void setMouseFunction( void (*mouseFunction) (Control*, Event*) )
        {
            this->mouseFunction=mouseFunction;
        }
    };
    
    
    void mouseFunction (Control* control, Event* event)
    {
        printf ("test");
    }
    
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    
        Control c;
        c.setMouseFunction(mouseFunction);
        Event e = 1;
        c.mouseFunction(&c,&e);
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with jQuery click event handling. Here's my code: $j(#btn_renommer_groupe).click(function(){ document.forms['creation_edition_groupe'].reset();
i have one problem with handling list,i have three class named as UserInf,userData,userProcess,i created
I experience strange problem. We have error handling in global.asax that would redirect user
I have a program doing something like the following: class SomeObject{} { void function(int
I have a class for session handling that uses object overloading for __GET and
I have a problem with handling the function to update my gridview. Until now
i have an problem with handling data come from server , please see the
I have a problem with slashes! I have some jQuery for handling generic dialogs
I have a problem with handling json variables in javascript. The problem appears when
I have a problem with socket send (or write) function on android. There is

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.