linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darío Mariani" <dmarian@fi.uba.ar>
To: linux-c-programming@vger.kernel.org
Subject: Re: function pointers in C++
Date: Mon, 15 Mar 2004 11:38:00 -0300	[thread overview]
Message-ID: <4055BFC8.4040609@fi.uba.ar> (raw)
In-Reply-To: <1079342899.405577335bb24@webmail.uoa.gr>

Probably what you need is the "pointer to member". It's described in
chapter 15, section 5 in "The C++ Programming Language", from Stroustrup.

elathan@phys.uoa.gr wrote:
> Hello! 
>  
> Suppose I have: 
>  
> class Foo 
> { 
> public: 
> 	Foo(); 
> 	~Foo(); 
> 	int bar(int); 
> }; 
>  
> Now, why I can't do this: 
>  
> Foo *f = new Foo(); 
> taz(f->bar); 
>  
> Where taz()'s protype is: 
>  
> void taz(int (*f)(int)); 
>  
> In plain C, I can do: 
>  
> int f(int) { ... } 
> taz(f); 
>  
> without a problem. Is there a way to accomplish such a thing (i.e. 
> to pass the pointer of a C++ class's member function to another 
> function that expects a pointer to function as an argument)? 
>  
> Regards, 
> --  
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



  parent reply	other threads:[~2004-03-15 14:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-15  9:28 function pointers in C++ elathan
2004-03-15 10:27 ` Jan-Benedict Glaw
2004-03-15 10:39   ` elathan
2004-03-15 14:38 ` Darío Mariani [this message]
2004-03-15 14:56   ` Darío Mariani
2004-03-15 19:10 ` Ashutosh Ranjan
  -- strict thread matches above, loose matches on Subject: below --
2004-03-15 14:21 Sandro Dangui
2004-03-15 11:28 ` Elias Athanasopoulos
2004-03-16  7:50   ` Glynn Clements
2004-03-18 11:17     ` Elias Athanasopoulos
2004-03-15 21:59 Sandro Dangui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4055BFC8.4040609@fi.uba.ar \
    --to=dmarian@fi.uba.ar \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).