Message: Re: output file using ostream Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Feedback Re: output file using ostream 

Forum: Processes Involving Optical Photons
Re: Question output file using ostream (Lilia Drakopoulou)
Date: 14 Sep, 2011
From: Neil Fazel <Neil Fazel>

On Mon, 12 Sep 2011 17:26:25 GMT, Lilia Drakopoulou wrote:
> Hello!
> 
> I want to have my results in an output file so I used the following
> code:
> 
> #include "MySession.hh"
> #include "globals.hh"
> #include "G4ios.hh"
> #include "G4Types.hh"
> #include <iostream>
> #include "G4coutDestination.hh"
> 
> MySession::MySession() {}
> 
> MySession::~MySession() {}
> 
>   ostream logFile;
>   logFile.open("MylogFile");
> 
> G4int MySession::ReceiveG4cout(G4String coutString)
> {
>   logFile << coutString << flush;
>   return 0;
> }
> 
> But it turns out this message and I really can't solve it. Any
> suggestion how to make it work?
> ...

I think you need to add

using namespace std;

Also, consider using ofstream when writing to a file. See here:

http://www.cplusplus.com/reference/iostream/

Neil

 Add Message Add Message
to: "Re: output file using ostream"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews