Message: Re: G4cout weird behaviour Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

More Re: G4cout weird behaviour 

Forum: Documentation and Examples
Re: Question G4cout weird behaviour (Hans Wenzel)
Date: 31 Jan, 2009
From: Krisztian Balla <Krisztian Balla>

Have you tried removing the integer?

If you look at the G4String class reference: http://www.lcsim.org/software/geant4/doxygen/html/classG4String.html

You'll see that unfortunately there is no implementation for the operator+(int).

G4String is based on std::string (see here: http://geant4.cern.ch/bin/SRM/G4GenDoc.exe.pl?flag=2&FileName=G4String.hh&FileDir=source/global/management/include) and if you look here: http://www.cplusplus.com/reference/string/string/operator+=.html

There is also no implementation of operator+(int) in std::string. I guess you have to do something like this:

char buffer[10]; sprintf(buffer, "i=%d", 400); G4String str = buffer;

That is the way I do it and it works. Good luck!

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Idea: Re: G4cout weird behaviour   (Krisztian Balla - 31 Jan, 2009)
(_ Question: Re: G4cout weird behaviour   (Krisztian Balla - 31 Jan, 2009)
 Add Message Add Message
to: "Re: G4cout weird behaviour"

 Subscribe Subscribe

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


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]