home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / windows / openloo / 3715 < prev    next >
Encoding:
Internet Message Format  |  1992-09-03  |  1.4 KB

  1. Path: sparky!uunet!tdat!swf
  2. From: swf@teradata.com (Stanley Friesen)
  3. Newsgroups: comp.windows.open-look
  4. Subject: Re: Q: C++ and callback problems.
  5. Keywords: callback OI
  6. Message-ID: <982@tdat.teradata.COM>
  7. Date: 2 Sep 92 21:58:36 GMT
  8. References: <Btpy3G.Dnu@solbourne.com> <1992Aug30.171624.1330@isy.liu.se>
  9. Sender: news@tdat.teradata.COM
  10. Reply-To: swf@tdat.teradata.com (Stanley Friesen)
  11. Organization: NCR Teradata Database Business Unit
  12. Lines: 25
  13.  
  14. In article <1992Aug30.171624.1330@isy.liu.se> svan@isy.liu.se writes:
  15. |>
  16. |>    // call MyClass::bar when button activated
  17. |>    cellp->change_action( mcp, (OI_action_memfnp) &MyClass::bar );
  18. |
  19. |What is OI_action_memfnp? For this to be a legal and portable (?) cast it
  20. |has to be of type pointer-to-member-of-MyClass or a pointer-to-member-of-a-
  21. |-baseclass-of-MyClass. 
  22. |I suppose in this case that MyClass is derived from an OI-class? (hence the
  23. |lacking of a cast of mcp in the last call.) Is it really safe to make a 
  24. |member-function-call when both the objectpointer and the pointer-to-member-
  25. |-function have been casted "towards the baseclass"?
  26.  
  27. You suppose correctly. To register a member function as a callback, the
  28. first base class of MyClass must be the OI class OI_callback.
  29.  
  30. And, no, it is not safe, you had better be sure that the member function
  31. pointer you are passing actually pertains to the object pointer you are
  32. passing.
  33.  
  34.  
  35. -- 
  36. sarima@teradata.com            (formerly tdatirv!sarima)
  37.   or
  38. Stanley.Friesen@ElSegundoCA.ncr.com
  39.