[comp.lang.c++] ostream/istream question

James.Reilly@tel.vtt.fi (Jim Reilly) (11/22/90)

Hey,

I just got ObjectWorks C++ (1.02) that uses Cfront (2.0).
I am having problems porting some code that constructs istreams
from existing istreams.

For example:

  #include <iostream.h>

  main() {
    istream output(cout);
  }

gives:
  put:"j.c", line 6: error:  ostream::ostream() cannot access ios::ios():
  private  member

What I'm trying to do is something like this:

  class Ostream {
    private: ostream& os;
    public: Ostream (ostream& out) : os(out) {}
    // ...
  };

Some Questions:
Q1: Is there some reason why I shouldn't be able to construct streams
    from other streams, using the X(const X&) constructor ?

Q2: Does anyone have any suggestions for what I should do in this case ?

Q3: Has think been fixed in Cfront 2.1+ ?

It seems to me much of this could be resolved if I could simply read
the fd of the stream, but I don't think I can do this for an ostream/istream
without cheating (unless it is an ifstream or ofstream), or am I just
being brain dead and missing something completely obvious ?

If anyone has any other helpful comments/hints/suggestions regarding the 
AT&T streams library, I'd be grateful to see them, as I don't have an
AT&T Refernece Manual for Cfront available.

please respond via e-mail to reilly@tel.vtt.fi, as I don't
read NetNews too often.

	thanks !
	jim 

--
Internet Mailbox: 	James.Reilly@tel.vtt.fi
UUCP Mailbox:		...!{mcsun, uunet}!tel.vtt.fi!reilly

James.Reilly@tel.vtt.fi (Jim Reilly) (11/22/90)

Oooops,

Of course I meant to construct istreams from istreams and
ostreams from ostreams (and not as I fat-fingered in my first post) :

 istream input(cin);
 ostream output(cout);

class Ostream {
  private:
    ostream& os;
  public:
    Ostream (ostream &out) : os(out) {}
    ...

Sorry,

jim
--
Internet Mailbox: 	James.Reilly@tel.vtt.fi
UUCP Mailbox:		...!{mcsun, uunet}!tel.vtt.fi!reilly