home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.std.c++:1537 comp.lang.c++:16089
- 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
- From: dlarsson@aut.abb.se (Daniel Larsson)
- Newsgroups: comp.std.c++,comp.lang.c++
- Subject: Operator -> cannot return non-class types?
- Summary: HP C++ 3.0 won't allow me to return e.g. char* from operator ->
- Keywords: HP C++ 3.0, operator ->
- Message-ID: <1992Nov11.092316.306@aut.abb.se>
- Date: 11 Nov 92 09:23:16 GMT
- Organization: ABB Automation AB, Vasteras, Sweden
- Lines: 34
-
- Yesterday, I tried HP's new C++ compiler (3.0) and templates for the first
- time. To my surprise, I noticed that operator -> can only return the following
- three types:
- - a pointer to a class,
- - a class, or
- - a reference to a class.
-
- This means I cannot do simple things like:
-
- template< class T >
- class OffsetPtr
- {
- public:
- OffsetPtr();
- OffsetPtr( T* );
- ...
- T* operator ->();
- ...
- };
-
- OffsetPtr<char> ptrToString;
-
-
- What is the rationale behind this restriction? I couldn't find anything in
- C++PL 2nd ed. that mentions this restriction, although I didn't look too hard.
-
- -- Daniel
-
-
- --
- ---------------------------------------------------------------------------
- Daniel Larsson Email: dlarsson@aut.abb.se
- ABB Automation AB Telefax: +46 21 34 25 25
- V{ster}s, Sweden Telephone: +46 21 34 30 29
-