TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ADAM MAJER
from: THOMAS MAEDER
date: 1997-11-16 15:02:00
subject: `Use :: to get the addres

AM> exist more than once in memory. For example, how can I take a pointe
AM> to the following function and call it from that pointer? Thanx.
AM> class Boo : public TWindow
AM> {
AM>         *
AM>         *
AM>         *
AM>         void TempFunction();   <- non static
AM> };
void (Boo::*ptrToBooMemberFct)();
ptrToBooMemberFct = Boo::TempFunction;
To invoke it, you can use the following syntax:
Boo a;
(a.*ptrToBooMemberFct)();   // dereferenciation via variable
Boo *b = &a;
(b->*ptrToBooMemberFct)();  // dereferenciation via pointer
The following
void (*ptrToBooMemberFct)();
doesn't  work  because  every  non-static member function is passed an
implicit pointer (this) to the instance the method is applied on.
Thomas
---
 þ MM 1.0 #0113 þ Drop your carrier...we have you surrounded!
---------------
* Origin: McMeier & Son BBS (2:301/138)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.