linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: elathan@phys.uoa.gr
To: linux-c-programming@vger.kernel.org
Subject: function pointers in C++
Date: Mon, 15 Mar 2004 11:28:19 +0200	[thread overview]
Message-ID: <1079342899.405577335bb24@webmail.uoa.gr> (raw)

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, 
--  


             reply	other threads:[~2004-03-15  9:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-15  9:28 elathan [this message]
2004-03-15 10:27 ` function pointers in C++ Jan-Benedict Glaw
2004-03-15 10:39   ` elathan
2004-03-15 14:38 ` Darío Mariani
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=1079342899.405577335bb24@webmail.uoa.gr \
    --to=elathan@phys.uoa.gr \
    --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).