Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Function pointer, is this possible?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
lil...@dcccd.edu  
View profile  
 More options Jun 16 2009, 1:38 pm
Newsgroups: comp.lang.c++
From: lil...@dcccd.edu
Date: Tue, 16 Jun 2009 12:38:14 -0500
Local: Tues, Jun 16 2009 1:38 pm
Subject: Function pointer, is this possible?
Hopefully I can describe this in a clear manner.

I've created a button class with private member

    (int) (* func) (void);

This is set using

void BTN::SetFunction(int (*fnc)(void))
{
        func = fnc;

}

This compiles fine.  The problem comes when I use SetFunction to
assign the function I want to run.  Under straight forward
circumstances this should compile fine.  However, the function I want
to set it to is a public member of another class object, bg of class
Grid.

  btnNew.SetFunction ( bg.SetNewMode );

But I get a repremand to

"use '&Grid::SetNewMode' to create a pointer to member"

Does this mean that I can only specify a static function of a class?
The more I think about this I can see why the compiler chokes on this.
Aside from providing discete functions to wrap the call to
bg.SetNewMode() is there any way to use a function pointer with a
non-static function of a class?

--
Lilith


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.