home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16375 < prev    next >
Encoding:
Internet Message Format  |  1992-11-17  |  1.3 KB

  1. Path: sparky!uunet!mcsun!Germany.EU.net!Urmel.Informatik.RWTH-Aachen.DE!dfv.rwth-aachen.de!sungate.fido.de!p1.hippo.fido.de!spam.fido.de!Gilles_Kohl
  2. Date: Sun, 15 Nov 92 09:01:00 +0100
  3. From: Gilles_Kohl@spam.fido.de (Gilles Kohl)
  4. Subject: Re: Operator -> cannot return non-class types?
  5. Message-ID: <a008546a@p3.f6.n249.z2.fidonet.org>
  6. References: <b5327e91@aut.abb.se>
  7. Newsgroups: comp.lang.c++
  8. X-Comment-To: (Daniel Larsson)
  9. Organization: This origin line is inoperative. Call support at 
  10. Lines: 23
  11.  
  12.  > Yesterday, I tried HP's new C++ compiler (3.0) and templates for the
  13.  > first time. To my surprise, I noticed that operator -> can only return the
  14.  > following
  15.  > three types:
  16.  >    - a pointer to a class,
  17.  >    - a class, or
  18.  >    - a reference to a class.
  19.  
  20.  > What is the rationale behind this restriction? I couldn't find anything
  21.  > in C++PL 2nd ed. that mentions this restriction, although I didn't look too
  22.  > hard.
  23. Daniel,
  24.  
  25. I think the following on page 594 of C++PL2 applies:
  26.  
  27. r.13.4.6 Class Member Access
  28.  
  29. (...) An expression x->m is interpreted as (x.operator->())->m for a class 
  30. object x. It follows that operator-> must return either a pointer to a class or 
  31. an object of or a reference to a class for which operator->() is defined. 
  32. operator->() must be a nonstatic member function.
  33.  
  34. ---
  35.