Returning a multidimensional array from a function

Hello, how are you?

I am a beginner c++ programmer and I am having trouble returning a multidimensional array from a function. I know I have to use a pointer but I am a little confused on how.

here is the code,The C and S are global variables.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void POAMJ(double ResponseAvg[][S],double ResponseSTD[][S],double* POAptr){


	double mean;
	double StDev;
	POAptr = new double[C][S];
	for(m = 0; m < C; m++) {
		for(j=0;j< S;j++){
                        mean = log( ResponseAvg[m][j] ) - 0.5 * log( 1 + pow(ResponseSTD[m][j], 2) / pow(ResponseAvg[m][j], 2) );
			StDev = sqrt( log(1 + pow(ResponseSTD[m][j], 2) / pow(ResponseAvg[m][j], 2) ) );
			POAptr[m][j]=logNormDist(60,mean,StDev);
		}
	}
}


Can Somebody help me out?


Thank you,
Does the code compile? What is the trouble that you are having? Compile or run-time errors? Please post a more specific question related to the code that you've posted. I'm not sure if you can use variables in the declaration like that or not. I've never tried it. There isn't enough in what you have posted for me to conveniently try to compile and execute the program.
This article should help you understand. It contains an explicit example on how to construct the 2d array.
http://cplusplus.com/forum/articles/7459/
Topic archived. No new replies allowed.