home *** CD-ROM | disk | FTP | other *** search
- #if 0
- From:
- Subject: operator->() bug
- Status: Fixed in 3.0b3
- #endif
-
- // Question : Shouldn't this operator-> overload be recursive in nature as
- // implied on page 337 of the ARM? this returns an error that "pointer required
- // before '->'...". This code works on Sun's CC (CFRONT 2.0 Based) and MAC.
- // 2.17 doesn't react any differently???
-
- #include <stdio.h>
-
- class obj;
-
- class ref
- {
- obj* myObj;
- public:
- ref(obj* anObj) : myObj(anObj) {}
- ref(ref& other) : myObj(other.myObj) {}
- obj *operator->() {return myObj;}
- };
-
- class hand
- {
- obj *myObj;
- public:
- hand(obj *anObj) : myObj(anObj) {}
- ref operator->();
- };
-
- class obj
- {
- public:
- int foo();
- };
-
- int obj::foo() { return 42; }
-
- void main()
- {
- obj mainObj;
- hand mainHand(&mainObj);
- int theAns = mainHand->foo();
- printf("%d\n",theAns);
- };
-