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

Question How to return multi-dim arrays? 

Keywords: multidimensional array, return value, member function, type definition
Forum: Analysis
Date: 13 Jan, 2005
From: Matthias Boehm <boehm@meissner-consulting.com>

Hello

I have a 3-dim array as data member inside a class.

Now I want to write a member function, which returns a pointer to this array. I just don't know what type the return value of the function has to be. A (G4double*) works fine if I return a 1-dim array. But when returning a 3-dim I get the compiler error:

"error C2440: 'return' : cannot convert from 
 'G4double [11][10][30]' to 'G4double *' "  

Using (G4double [11][10][30]) as a type does also not work. How can I define the type of a 3-dim array?

Please see the code below:

   G4double	depESum[11][10][30];
   G4double	depESum_1[11];

   G4double* GetDepESum_1()  { 
	return depESum_1; 
   };		// returns pointer to the 1D array
                //  works fine.

   G4double*  GetDepESum() {
	return depESum;	
   };	// returns pointer to the 3-D array
        // does not work!

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?   (John Allison - 14 Jan, 2005)
(_ None: Re: How to return multi-dim arrays?   (John Allison - 14 Jan, 2005)
(_ None: Re: How to return multi-dim arrays?   (Jeremy McCormick - 14 Jan, 2005)
 Add Message Add Message
to: "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 ]