TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: JOSHUA BOEHME
from: THOMAS MAEDER
date: 1997-05-26 20:27:00
subject: Virtual Function Pointers

JB> 		virtual void Show(void);
JB> 		virtual void Hide(void);
JB> 	public:
JB> 		void (*ShowPoint)(void);
JB> 		void (*HidePoint)(void);
JB>                                                      ShowPoint = ::S
JB>                                                      HidePoint = ::H
JB>                                         // Those two lines are the p
JB>                                         // have tried various combin
JB>                                         // &, :: and (), without suc
No, they aren't. Nor is the fact that Show and Hide are  virtual.  The
declarations  of  ShowPoint and HidePoint are the culprit. Change them
into
void (Point::*ShowPoint)(void);
void (Point::*HidePoint)(void);
and initialize them like this:
ShowPoint = Show;
HidePoint = Hide;
So much for your function pointer problem.  I  think  that  you  could
solve  your  problems  without  pointers  to (member) functions if you
improved the design. E.g. I don't think  that  it's  a  good  idea  to
derive  Point  from  Co_ordinates;  derivation  is  good for modelling
"is-a" relationships between classes, but a point isn't  a  coordinate
pair:  a point has a position which can be represented as a coordinate
pair.
Thomas
---
 þ MM 1.0 #0113 þ I'm the one your mother warned you about.
---------------
* 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™.