home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.windows.open-look
- Path: sparky!uunet!mcsun!sunic!liuida!isy!isy.liu.se!svan
- From: svan@isy.liu.se (Jonas Svanberg)
- Subject: Re: Q: C++ and callback problems.
- Message-ID: <1992Sep4.072144.27113@isy.liu.se>
- Keywords: callback C++ c++
- Sender: news@isy.liu.se (Lord of the News)
- Reply-To: svan@isy.liu.se
- Organization: Linkoping University
- References: <982@tdat.teradata.COM>
- Date: Fri, 4 Sep 1992 07:21:44 GMT
- Lines: 33
-
- swf@teradata.com (Stanley Friesen) responds:
-
- > In article <1992Aug30.171624.1330@isy.liu.se> svan@isy.liu.se writes:
- > |>
- > |> // call MyClass::bar when button activated
- > |> cellp->change_action( mcp, (OI_action_memfnp) &MyClass::bar );
- > |
- > |What is OI_action_memfnp? For this to be a legal and portable (?) cast it
- > |has to be of type pointer-to-member-of-MyClass or a pointer-to-member-of-a-
- > |-baseclass-of-MyClass.
- > |I suppose in this case that MyClass is derived from an OI-class? (hence the
- > |lacking of a cast of mcp in the last call.) Is it really safe to make a
- > |member-function-call when both the objectpointer and the pointer-to-member-
- > |-function have been casted "towards the baseclass"?
- >
- > You suppose correctly. To register a member function as a callback, the
- > first base class of MyClass must be the OI class OI_callback.
- >
- > And, no, it is not safe, you had better be sure that the member function
- > pointer you are passing actually pertains to the object pointer you are
- > passing.
-
- Yeah, but even if the memb-func-pointer does match the object-pointer, I
- wonder if it is safe... Especially when considering multiple inheritance.
-
-
- --------------------------------------------------------------
- Jonas Svanberg
- Department of Electrical Engineering
- Link÷ping University
- S-581 83 Link÷ping, Sweden Email: svan@isy.liu.se
- --------------------------------------------------------------
-
-