home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!iWarp.intel.com|inews.Intel.COM!cad734!rcox
- From: rcox@cad734.NoSubdomain.NoDomain (Richard Cox)
- Subject: iostreams inheritence question
- Message-ID: <BuL958.1MH@nntp-sc.Intel.COM>
- Sender: rcox@cad734 (Richard Cox)
- Nntp-Posting-Host: cad734
- Organization: Intel Corporation, Santa Clara, CA USA
- Date: Mon, 14 Sep 1992 22:00:43 GMT
- Lines: 65
-
- Please let me know if I am just being stupid or what?
-
- I am trying to develop a class from iostream and fstream which will
- allow a common class for all I/O in my code. I would like to make a
- pointer of type ios <iostream.h> and make it point to cout. cout is of
- type ostream_withassign and derived from ostream which is derived from
- ios. In ARM pg. 197 (chap 10) shows the following example:
-
- class base {...}
- class derived : public base {...}
-
- void f()
- {
- derived d;
- ...
- base * bp = &d;
- }
-
- I would like to do something like the following:
-
- #include <iostream.h>
- #include <fstream.h>
-
- main ()
- {
- ios &out = cout;
- out << "Grateful Dead" << endl; // this is line #13
- }
-
- but I get the followin errors:
-
- "streamT.C", line 13: error: bad operand types ios char [14] for <<
- "streamT.C", line 13: error: function operand for <<
-
- The only thing I can determine might be causing a problem is that
- ostream is delcared as:
-
- class ostream : virtual public ios {...}
-
- but I thought that just allowed overloading of all the methods in ios.
-
- Thanks in advance for the help...
-
- -Rich
-
- +-----------------------------------------------------------------------------+
- |Rich Cox E-Mail: rcox@scdt.intel.com |
- |CAD Developer AOL: Rich Kid |
- |Intel Corp. Mailstop: SC3-39 |
- | Phone: (408) 765-5199 |
- |-----------------------------------------------------------------------------+
- | These opinions are shared by everyone, I asked them... |
- +-----------------------------------------------------------------------------+
-
-
-
- --
- +-----------------------------------------------------------------------------+
- |Rich Cox E-Mail: rcox@scdt.intel.com |
- |CAD Developer AOL: Rich Kid |
- |Intel Corp. Mailstop: SC3-39 |
- | Phone: (408) 765-5199 |
- |-----------------------------------------------------------------------------+
- | These opinions are shared by everyone, I asked them... |
- +-----------------------------------------------------------------------------+
-