home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / sgi / 11615 < prev    next >
Encoding:
Internet Message Format  |  1992-07-29  |  1.0 KB

  1. Xref: sparky comp.sys.sgi:11615 comp.lang.c++:11757
  2. Newsgroups: comp.sys.sgi,comp.lang.c++
  3. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!mips!odin!fido!shankar
  4. From: shankar@sgi.com (Shankar Unni)
  5. Subject: Re: C++ member pointer error
  6. Message-ID: <ntqlk2k@fido.asd.sgi.com>
  7. Sender: news@fido.asd.sgi.com (Usenet News Admin)
  8. Organization: Silicon Graphics, Inc.
  9. References: <1992Jul28.184745.2854@babbage.ece.uc.edu>
  10. Date: Wed, 29 Jul 1992 21:34:32 GMT
  11. Lines: 18
  12.  
  13. In article <1992Jul28.184745.2854@babbage.ece.uc.edu> tmcbraye@snert.ece.uc.edu (Tim McBrayer) writes:
  14.  
  15. >  cout << (e.fn)(i) << endl;  //ERROR: (*(e.fn))(i) gives the same error
  16.            ^^^^^^
  17.  
  18. A pointer-to-member-function *must* be called through an object of
  19. that class. In your example, "e.fn" must be called through an object
  20. of class "V".  In the portion of the example, the most likely such
  21. object is the "this" of "V::run".
  22.  
  23. Thus
  24.  
  25.    cout << (this->*(e.fn))(i) << endl;
  26.  
  27. should do what you expect..
  28. --
  29. Shankar Unni                E-Mail:    shankar@sgi.com
  30. Silicon Graphics Inc.            Phone:    +1-415-390-2072
  31.