Message: Re: How to return multi-dim arrays? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: How to return multi-dim arrays? 

Keywords: multidimensional array, return value, member function, type definition
Forum: Analysis
Re: Question How to return multi-dim arrays? (Matthias Boehm)
Re: None Re: How to return multi-dim arrays? (John Allison)
Date: 14 Jan, 2005
From: John Allison <John Allison>

Realised it's more economical to use the C++ feature of references to return the array (vector of vectors of vectors of doubles):

 typedef std::vector<std::vector<std::vector<double> > > three;
 three depESum(11);

 three& GetDepESum() {
   // Fill the array...
   ...
   return depESum; 
 };   // returns pointer to the 3-D array

 main() {
   three x = GetDepESum();
   std::cout << x[1][2][3] << std::endl;
 }

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

1 None: Re: How to return multi-dim arrays?   (Jeremy McCormick - 14 Jan, 2005)
 Add Message Add Message
to: "Re: How to return multi-dim arrays?"

 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 ]