Message: Array indexing requires G4int? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Array indexing requires G4int? 

Forum: Documentation and Examples
Date: 01 Jul, 2011
From: Youming Yang <Youming Yang>

Hello,

I have some pretty simple code where I define:
          G4double x[3];

And I try to index it via:
          x[1];

I get errors to the tune of:
          error: invalid types 'G4double[int]' for array subscript

I can resolve it by indexing the array via a specially created G4int:
          G4int one=1;
          x[one];

But this seems somewhat ridiculous to need to typecast an int into G4int before every time I index an array. I was just wondering if this was the proper best practice in indexing arrays in Geant4?

Thanks, Ming

 Add Message Add Message
to: "Array indexing requires G4int?"

 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 ]