home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13635 < prev    next >
Encoding:
Text File  |  1992-09-14  |  2.6 KB  |  77 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!iWarp.intel.com|inews.Intel.COM!cad734!rcox
  3. From: rcox@cad734.NoSubdomain.NoDomain (Richard Cox)
  4. Subject: iostreams inheritence question
  5. Message-ID: <BuL958.1MH@nntp-sc.Intel.COM>
  6. Sender: rcox@cad734 (Richard Cox)
  7. Nntp-Posting-Host: cad734
  8. Organization: Intel Corporation, Santa Clara, CA USA
  9. Date: Mon, 14 Sep 1992 22:00:43 GMT
  10. Lines: 65
  11.  
  12. Please let me know if I am just being stupid or what?  
  13.  
  14. I am trying to develop a class from iostream and fstream which will
  15. allow a common class for all I/O in my code.  I would like to make a
  16. pointer of type ios <iostream.h> and make it point to cout.  cout is of
  17. type ostream_withassign and derived from ostream which is derived from
  18. ios.  In ARM pg. 197 (chap 10) shows the following example:
  19.  
  20. class base {...}
  21. class derived : public base {...}
  22.  
  23. void f()
  24. {
  25.     derived d;
  26.     ...
  27.     base * bp = &d;
  28. }
  29.  
  30. I would like to do something like the following:
  31.  
  32. #include <iostream.h>
  33. #include <fstream.h>
  34.  
  35. main () 
  36. {
  37.     ios &out = cout;
  38.     out << "Grateful Dead" << endl;   // this is line #13
  39. }
  40.  
  41. but I get the followin errors:
  42.  
  43. "streamT.C", line 13: error: bad operand types ios  char [14] for <<
  44. "streamT.C", line 13: error:  function operand for  <<
  45.  
  46. The only thing I can determine might be causing a problem is that
  47. ostream is delcared as:
  48.  
  49. class ostream : virtual public ios {...} 
  50.  
  51. but I thought that just allowed overloading of all the methods in ios.
  52.  
  53. Thanks in advance for the help...
  54.  
  55. -Rich
  56.  
  57. +-----------------------------------------------------------------------------+
  58. |Rich Cox                                              E-Mail: rcox@scdt.intel.com           |
  59. |CAD Developer                             AOL: Rich Kid                      |
  60. |Intel Corp.                     Mailstop: SC3-39               |
  61. |                                        Phone: (408) 765-5199              |
  62. |-----------------------------------------------------------------------------+
  63. | These opinions are shared by everyone, I asked them...                      |
  64. +-----------------------------------------------------------------------------+
  65.  
  66.  
  67.  
  68. -- 
  69. +-----------------------------------------------------------------------------+
  70. |Rich Cox                                              E-Mail: rcox@scdt.intel.com           |
  71. |CAD Developer                             AOL: Rich Kid                      |
  72. |Intel Corp.                     Mailstop: SC3-39               |
  73. |                                        Phone: (408) 765-5199              |
  74. |-----------------------------------------------------------------------------+
  75. | These opinions are shared by everyone, I asked them...                      |
  76. +-----------------------------------------------------------------------------+
  77.