home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: jlilley@ix.netcom.com (John Lilley)
- Newsgroups: comp.lang.c++
- Subject: Re: [HELP] ostream inheritance Q?
- Date: 29 Mar 1996 18:24:25 GMT
- Organization: Netcom
- Message-ID: <4jh9sp$1gp@dfw-ixnews6.ix.netcom.com>
- References: <4jf4lc$t8l@ground.cs.columbia.edu>
- NNTP-Posting-Host: den-co10-17.ix.netcom.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-NETCOM-Date: Fri Mar 29 12:24:25 PM CST 1996
- X-Newsreader: WinVN 0.99.7
-
- In article <4jf4lc$t8l@ground.cs.columbia.edu>, jean@news.cs.columbia.edu says...
- >
- >
- > i'm trying to come up with new output stream, say Nostream,
- >which provides some more functionality beyond ostream as follows.
- >
- >--------------------------------------------------
- >class Nostream : public ostream {
- >public:
- > Nostream(streambuf *sb) : ios(sb) {}
- > ~Nostream() {}
- >
- > Nostream& foo(const char *msg) {
- > return *this << mime;
- > }
- >
- > Nostream& operator << ( Nostream& (*funcPtr)(const char *msg)
- >) {
- > return (*funcPtr)(msg);
- > }
- >
- > .... // some more functionality...
- >}
- >
- >int main()
- >{
- > Nostream nout(cout.rdbuf());
- >
- > nout << "TEST" << endl;
- >
- > nout.header("blah"); --------- 1
- > nout << header("blah"); --------- 2
- >}
- >--------------------------------------------------
- >
- > ....
- >"foo.C", line 38: Error: msg is not defined. <<<--------!!!!
-
- Right. msg is not an argument of operator<<. It is an argument of
- the type of function pointer that is being passed to operator<<,
- but that is a different matter.
-
- And what in the world is:
- nout.header("blah");
- Has header been defined as a method of Nostream?
-
- As for
- nout << header("blah");
- this is the same as
- nout.operator<<(header("blah"))
- which is passing the *return value* of the (undefined)
- method/function header called with "blah". Once you
- define "header", and get an idea of what it's return
- value is, then you can try this again...
-
- john lilley
-
-
-
-
-