home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / std / cplus / 1537 < prev    next >
Encoding:
Text File  |  1992-11-11  |  1.4 KB  |  47 lines

  1. Xref: sparky comp.std.c++:1537 comp.lang.c++:16089
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!news2me.EBay.Sun.COM!seven-up.East.Sun.COM!sixgun.East.Sun.COM!sungy!news.Sweden.Sun.COM!swippy!seunet!abbaut!dlarsson
  3. From: dlarsson@aut.abb.se (Daniel Larsson)
  4. Newsgroups: comp.std.c++,comp.lang.c++
  5. Subject: Operator -> cannot return non-class types?
  6. Summary: HP C++ 3.0 won't allow me to return e.g. char* from operator ->
  7. Keywords: HP C++ 3.0, operator ->
  8. Message-ID: <1992Nov11.092316.306@aut.abb.se>
  9. Date: 11 Nov 92 09:23:16 GMT
  10. Organization: ABB Automation AB, Vasteras, Sweden
  11. Lines: 34
  12.  
  13. Yesterday, I tried HP's new C++ compiler (3.0) and templates for the first
  14. time. To my surprise, I noticed that operator -> can only return the following
  15. three types:
  16.    - a pointer to a class,
  17.    - a class, or
  18.    - a reference to a class.
  19.  
  20. This means I cannot do simple things like:
  21.  
  22.   template< class T >
  23.   class OffsetPtr 
  24.     {
  25.     public:
  26.       OffsetPtr();
  27.       OffsetPtr( T* );
  28.       ...
  29.       T* operator ->();
  30.       ...
  31.     };
  32.  
  33.   OffsetPtr<char> ptrToString;
  34.  
  35.  
  36. What is the rationale behind this restriction? I couldn't find anything in
  37. C++PL 2nd ed. that mentions this restriction, although I didn't look too hard.
  38.  
  39. -- Daniel
  40.  
  41.  
  42. -- 
  43. ---------------------------------------------------------------------------
  44. Daniel Larsson          Email:       dlarsson@aut.abb.se
  45. ABB Automation AB    Telefax:   +46 21 34 25 25
  46. V{ster}s, Sweden    Telephone: +46 21 34 30 29
  47.