home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!grebyn!daily!dougw
- From: dougw@grebyn.com (Doug Worthington)
- Subject: What is wrong with this, a simple question
- Message-ID: <1993Jan12.003246.14658@grebyn.com>
- Organization: Grebyn Timesharing
- Date: Tue, 12 Jan 1993 00:32:46 GMT
- Lines: 54
-
- Here is a snipt of code, why doesn't this work
-
- .h file
- ----------
- class foobar
- ....
- public:
- char operator [] (int index);
- ....
-
- .cc file
- -----------
- ....
- char foobar::operator [] (int index)
- {
- .....
- }
-
- source file This example works.
- -----------
-
- foobar fooBarThing();
-
- cout << fooBarThing[1];
-
- source file This example DOESN'T work
- ---------
-
- foobar *fooBarThing();
- /* allocat the foobar object */
-
- count << fooBarThing[1];
-
- Why does declaring the objecty as a pointer change the use of the index
- member function. The [] operater function isn't even called in the
- second example.
-
- Thanks for the help
-
- dougw
- dougw@grebyn.com
-
- P.S. please respond to me and not the net if you can.
-
-
-
-
-
-
-
-
-
-
-
-