home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / windows / openloo / 3735 < prev    next >
Encoding:
Text File  |  1992-09-04  |  1.8 KB  |  47 lines

  1. Newsgroups: comp.windows.open-look
  2. Path: sparky!uunet!mcsun!sunic!liuida!isy!isy.liu.se!svan
  3. From: svan@isy.liu.se (Jonas Svanberg)
  4. Subject: Re: Q: C++ and callback problems.
  5. Message-ID: <1992Sep4.072144.27113@isy.liu.se>
  6. Keywords: callback C++ c++ 
  7. Sender: news@isy.liu.se (Lord of the News)
  8. Reply-To: svan@isy.liu.se
  9. Organization: Linkoping University
  10. References: <982@tdat.teradata.COM>
  11. Date: Fri, 4 Sep 1992 07:21:44 GMT
  12. Lines: 33
  13.  
  14. swf@teradata.com (Stanley Friesen) responds:
  15.  
  16. > In article <1992Aug30.171624.1330@isy.liu.se> svan@isy.liu.se writes:
  17. > |>
  18. > |>    // call MyClass::bar when button activated
  19. > |>    cellp->change_action( mcp, (OI_action_memfnp) &MyClass::bar );
  20. > |
  21. > |What is OI_action_memfnp? For this to be a legal and portable (?) cast it
  22. > |has to be of type pointer-to-member-of-MyClass or a pointer-to-member-of-a-
  23. > |-baseclass-of-MyClass. 
  24. > |I suppose in this case that MyClass is derived from an OI-class? (hence the
  25. > |lacking of a cast of mcp in the last call.) Is it really safe to make a 
  26. > |member-function-call when both the objectpointer and the pointer-to-member-
  27. > |-function have been casted "towards the baseclass"?
  28. >
  29. > You suppose correctly. To register a member function as a callback, the
  30. > first base class of MyClass must be the OI class OI_callback.
  31. >
  32. > And, no, it is not safe, you had better be sure that the member function
  33. > pointer you are passing actually pertains to the object pointer you are
  34. > passing.
  35.  
  36. Yeah, but even if the memb-func-pointer does match the object-pointer, I
  37. wonder if it is safe... Especially when considering multiple inheritance.
  38.  
  39.  
  40. --------------------------------------------------------------
  41.  Jonas Svanberg
  42.  Department of Electrical Engineering
  43.  Link÷ping University
  44.  S-581 83 Link÷ping, Sweden             Email: svan@isy.liu.se
  45. --------------------------------------------------------------
  46.  
  47.