[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] stream problemer



Carsten Svaneborg <sslug@sslug> wrote:

> Det jeg gerne vil lave i starten er en
> ostream& out;
> ofstream fo;
> 
> if (!outputfile) out=cout;
>             else {
>                       fo.open(...)
>                       out=fo;
>                    }
> 
> og så bare skrive
> 
> Udskriv(out,"whatever");
> 
> Men det syntes at at være besværligt at tildele cout til en vilkårlig
> ostream. Enten findes operator= ikke ellers er der klasse mismatch.

Du må nok bruge en pointer, hvis du vil lave tildelingen efter
definitionen af "out". Men kan du ikke bruge noget i stil med

        ostream& out = (outputfile) ? fo : cout;

? Ikke at jeg har afprøvet det.


Anders.


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *