[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



Nils Åke Ljunggren skrev

>"Tænk på en reference som en const-pointer (BS 3.ed.)!" (i modsætning til 

>en pointer til et const object)
>>ostream& out; //error
>// en reference skal altid initializeres (og "adressen" kan *normalt!* 
>ikke ændres)

>du slipper altså ikke uden om brugen af pointere!
Det kan nu aligevel godt lade sig gøre:

>hvordan -- hvorledes -- er en anden historie

#include <iostream>
#include <fstream>
extern bool outputfile;

int main() {
  using namespace std;
  ostream& out_ref= outputfile ? *new ofstream("outout") : cout;
  out_ref << "test" << endl;
  return int();
}


Jeg kender flere der ville finde ovenstående "Bad Programming Practice" -- 
men det var heldigvis ikke spørgsmålet?

mvh
Nils Åke Ljunggren!


 
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] *