🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: de.comp.lang.c++
Article #1872

Re: Probleme beim Vererben von fstream

#1872
From: Thomas Holubar
Date: Fri, 22 Mar 1996 00:05
39 lines
1818 bytes
Hallo Bernhard !

Ich mache es mir einmal einfach und gehe nicht explizit auf Dein Beispiel ein,
sondern gebe ein Beispiel zur Erzeugung einer "streamable class". Ich hoffe es
bringt Dich weiter:

Zunaechst: ein ueberladener stream-Operator _muss_ eine "friend-function" sein.
Ein Ausgabeoperator sieht dann in etwa so aus:

ostream & operator<< (ostream &os, Object &obj)
{
	os << "Objekt-atom1";
	os << "Objekt-atom2";
	...
	os << "Objekt-atom3";	// Objekt-atome sind z.B. die Teile einer 
				// Struktur etc.
	return os;		// Die stream-Referenz weiterreichen
}

Eine zugehoerige Klasse waere dann in etwa wie folgt zu definieren:

class AnyClass
{
	// evtl. Daten hier
	friend ostream & operator<< (ostream &, AnyClass &);
     public:
	// Konstruktoren etc.
};

Wenn Du das entsprechend auf Dein Problem hin modifizierst muesste es klappen.

Viel Erfolg!

Thomas
-- 
Thomas Holubar  / finger holubar@rz.uni-frankfurt.de for PGP key
                / eMail: holubar@stud.uni-frankfurt.de
                / WWW  : http://www.uni-frankfurt.de/~holubar
"Win95: from the people who brought you 'edlin' !" (seen on USENET)
Technical Details
Message-ID: <4isqrl$s7h@zeus.rbi.informatik.uni-frankfurt.de>
Path: arc1-ca.pugleaf.net!zeus.rbi.informatik.uni-frankfurt.de!usenet
References: <31486437.41C6@studi.epfl.ch>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!zeus.rbi.informatik.uni-frankfurt.de!usenet
From: Thomas Holubar <holubar@informatik.uni-frankfurt.de>
Newsgroups: de.comp.lang.c++
Subject: Re: Probleme beim Vererben von fstream
Date: 22 Mar 1996 00:05:09 GMT
Organization: J. W. Goethe-Universitaet Frankfurt/Main
Message-ID: <4isqrl$s7h@zeus.rbi.informatik.uni-frankfurt.de>
References: <31486437.41C6@studi.epfl.ch>
NNTP-Posting-Host: dialin160.rz.uni-frankfurt.de
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 1.1N (X11; I; Linux 1.2.6 i486)
To: Bernhard.Ruch@studi.epfl.ch
X-URL: news:31486437.41C6@studi.epfl.ch