Click here to Skip to main content
15,891,981 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionExchange SOAP Contacts Sync Pin
Alexander M.,12-Mar-10 5:19
Alexander M.,12-Mar-10 5:19 
AnswerRe: Exchange SOAP Contacts Sync Pin
Richard MacCutchan12-Mar-10 22:07
mveRichard MacCutchan12-Mar-10 22:07 
QuestionAllocation of (**)[2] [Solved] Pin
xuxiuxun12-Mar-10 4:17
xuxiuxun12-Mar-10 4:17 
AnswerRe: Allocation of (**)[2] Pin
Eugen Podsypalnikov12-Mar-10 4:32
Eugen Podsypalnikov12-Mar-10 4:32 
AnswerRe: Allocation of (**)[2] Pin
Chris Losinger12-Mar-10 4:32
professionalChris Losinger12-Mar-10 4:32 
AnswerRe: Allocation of (**)[2] Pin
xuxiuxun12-Mar-10 15:41
xuxiuxun12-Mar-10 15:41 
GeneralRe: Allocation of (**)[2] Pin
Richard MacCutchan12-Mar-10 22:06
mveRichard MacCutchan12-Mar-10 22:06 
GeneralRe: Allocation of (**)[2] Pin
xuxiuxun13-Mar-10 0:27
xuxiuxun13-Mar-10 0:27 
Maybe my previous description is not specific enough. Hope the code below explain more clearly.

int row0 = 0, col0 = 0;
float ***coords;
int Output1(out1[10][2]);
int Output2(out1[20][2], out2[20][2]);
int Output3(out1[30][2], out2[30][2], out3[30][2]);
int Output4(out1[40][2], out2[40][2], out3[40][2], out4[40][2]);

void Function(const int nMode)
{
     int row, col;

     switch (nMode)
     {
     case 0: row = 1; col = 10; break;
     case 1: row = 2; col = 20; break;
     case 2: row = 3; col = 30; break;
     case 3: row = 4; col = 40; break;
     }

     if (row0 != row || col0 != col)
     {
          coords = new float**[row];
          for (int i = 0; i < row; i++) {
               coords[i] = new float*[col];
               for (int j = 0; j < col; j++)
                    coords[i][j] = new float[2];   }
          row0 = row; col0 = col;
     }

     switch (nMode)
     {
     case 0: Output1(coords[0]);                                  break;
     case 1: Output2(coords[0], coords[1]);                       break;
     case 2: Output3(coords[0], coords[1], coords[2]);            break;
     case 3: Output4(coords[0], coords[1], coords[2], coords[3]); break;
     }

     // ... Other code goes on. Before quitting the program, coords will be deleted according to its dimensions.
}


So in this way, I do not need to declare a bunch of static arrays like:

float out1[10][2];
float out2[2][20][2];
float out3[3][30][2];
float out4[4][40][2];


And some of them may even not to be used throughout the process (if nMode sticks to a certain choice by user). Thus I think dynamic allocation will be more efficient. (Although the allocation and deallocation may cost some effort.)

Going back to original subject, my question is "Is it possible that I can use float (**)[2] instead of float***, since the dimension of the last layer is always 2?"

Thanks.
GeneralRe: Allocation of (**)[2] Pin
Richard MacCutchan13-Mar-10 10:07
mveRichard MacCutchan13-Mar-10 10:07 
GeneralRe: Allocation of (**)[2] Pin
xuxiuxun13-Mar-10 19:49
xuxiuxun13-Mar-10 19:49 
QuestionMessage Removed Pin
12-Mar-10 4:00
xuxiuxun12-Mar-10 4:00 
AnswerRe: Allocation of (**)[2] Pin
Chris Losinger12-Mar-10 4:14
professionalChris Losinger12-Mar-10 4:14 
GeneralRe: Allocation of (**)[2] Pin
xuxiuxun12-Mar-10 4:25
xuxiuxun12-Mar-10 4:25 
Questionwarning LNK4222: exported symbol 'DllRegisterServer' should not be assigned an ordinal Pin
sashoalm12-Mar-10 2:51
sashoalm12-Mar-10 2:51 
AnswerRe: warning LNK4222: exported symbol 'DllRegisterServer' should not be assigned an ordinal Pin
Eugen Podsypalnikov12-Mar-10 3:02
Eugen Podsypalnikov12-Mar-10 3:02 
GeneralRe: warning LNK4222: exported symbol 'DllRegisterServer' should not be assigned an ordinal Pin
sashoalm12-Mar-10 3:09
sashoalm12-Mar-10 3:09 
QuestionSeven : What Happended To ShellExecute ? Pin
Nicolas MEURET12-Mar-10 2:11
Nicolas MEURET12-Mar-10 2:11 
QuestionRe: Seven : What Happended To ShellExecute ? Pin
sashoalm12-Mar-10 3:23
sashoalm12-Mar-10 3:23 
AnswerRe: Seven : What Happended To ShellExecute ? [modified] Pin
Nicolas MEURET12-Mar-10 4:38
Nicolas MEURET12-Mar-10 4:38 
GeneralRe: Seven : What Happended To ShellExecute ? Pin
sashoalm12-Mar-10 5:27
sashoalm12-Mar-10 5:27 
QuestionHaving different value for a global variable per thread. Pin
Code-o-mat12-Mar-10 1:20
Code-o-mat12-Mar-10 1:20 
AnswerRe: Having different value for a global variable per thread. Pin
sunlin712-Mar-10 1:37
sunlin712-Mar-10 1:37 
GeneralRe: Having different value for a global variable per thread. Pin
Code-o-mat12-Mar-10 1:44
Code-o-mat12-Mar-10 1:44 
AnswerRe: Having different value for a global variable per thread. Pin
Jonathan Davies12-Mar-10 1:38
Jonathan Davies12-Mar-10 1:38 
GeneralRe: Having different value for a global variable per thread. Pin
Code-o-mat12-Mar-10 1:44
Code-o-mat12-Mar-10 1:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.