Click here to Skip to main content
15,911,762 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: typedef tweak Pin
led mike21-Nov-07 4:40
led mike21-Nov-07 4:40 
GeneralRe: typedef tweak Pin
jhwurmbach21-Nov-07 6:15
jhwurmbach21-Nov-07 6:15 
GeneralRe: typedef tweak Pin
led mike21-Nov-07 6:33
led mike21-Nov-07 6:33 
GeneralRe: typedef tweak Pin
jhwurmbach21-Nov-07 6:37
jhwurmbach21-Nov-07 6:37 
GeneralRe: typedef tweak Pin
Mark Salsbery21-Nov-07 7:00
Mark Salsbery21-Nov-07 7:00 
GeneralRe: typedef tweak Pin
led mike21-Nov-07 9:01
led mike21-Nov-07 9:01 
GeneralRe: typedef tweak Pin
Mark Salsbery21-Nov-07 6:57
Mark Salsbery21-Nov-07 6:57 
AnswerRe: typedef tweak Pin
Nathan Holt at EMOM21-Nov-07 10:49
Nathan Holt at EMOM21-Nov-07 10:49 
The easiest way to understand typedef is that it works the same way as if you were declaring a variable. If you were declaring a 2d array of cells, you could use CELL array[g_nNumRows][g_nNumCols];. If you put a typedef in front of the declaration, it gives a name to the type that such a variable would be.

The & is used to create a reference to the SPREADSHEET that will act like a value. In many cases, this is a good way to avoid using * for all your variable references, and to make sure you don't accidentally change the value of the pointer it hides. In this case, the effects are complicated by the way pointers act like arrays, so this might not be good code to start learning from.

The more appropriate way to write the last line might make more sense:
SPREADSHEET& g_ss = *reinterpret_cast<PSPREADSHEET>(m_pArray)
In this case, the C array/pointer equivalence is used again. Casting to and from void * is more common, and it is used for code that works on pointers without regard to the type pointed to.

I can see a couple problems in the code you have posted. The names of the array dimensions look like variable names, but array sizes declared that way have to be compile time constants. Also, there seems to be a sizeof(CELL) missing in the VirtualAlloc statement.

Nathan
GeneralRe: typedef tweak Pin
LiYS21-Nov-07 17:41
LiYS21-Nov-07 17:41 
QuestionDoes it take much time to do such a user interface? Pin
followait21-Nov-07 4:24
followait21-Nov-07 4:24 
AnswerRe: Does it take much time to do such a user interface? Pin
led mike21-Nov-07 4:35
led mike21-Nov-07 4:35 
GeneralRe: Does it take much time to do such a user interface? Pin
followait21-Nov-07 4:38
followait21-Nov-07 4:38 
GeneralRe: Does it take much time to do such a user interface? Pin
toxcct21-Nov-07 4:45
toxcct21-Nov-07 4:45 
JokeRe: Does it take much time to do such a user interface? Pin
Cedric Moonen21-Nov-07 4:47
Cedric Moonen21-Nov-07 4:47 
GeneralRe: Does it take much time to do such a user interface? Pin
followait21-Nov-07 15:40
followait21-Nov-07 15:40 
GeneralRe: Does it take much time to do such a user interface? Pin
toxcct21-Nov-07 21:15
toxcct21-Nov-07 21:15 
GeneralRe: Does it take much time to do such a user interface? Pin
Cedric Moonen21-Nov-07 4:45
Cedric Moonen21-Nov-07 4:45 
GeneralRe: Does it take much time to do such a user interface? Pin
followait21-Nov-07 15:41
followait21-Nov-07 15:41 
GeneralRe: Does it take much time to do such a user interface? Pin
Nelek21-Nov-07 20:39
protectorNelek21-Nov-07 20:39 
QuestionRe: Does it take much time to do such a user interface? Pin
Hamid_RT21-Nov-07 19:11
Hamid_RT21-Nov-07 19:11 
Questionoft used derived class(VC6/MFC) Pin
Tara1421-Nov-07 4:21
Tara1421-Nov-07 4:21 
AnswerRe: oft used derived class(VC6/MFC) Pin
Nelek21-Nov-07 20:36
protectorNelek21-Nov-07 20:36 
QuestionHelp with C++ Win32 GDI Program Pin
Jason Daniel Cohn21-Nov-07 3:52
Jason Daniel Cohn21-Nov-07 3:52 
AnswerRe: Help with C++ Win32 GDI Program Pin
KarstenK21-Nov-07 4:00
mveKarstenK21-Nov-07 4:00 
AnswerRe: Help with C++ Win32 GDI Program Pin
CPallini21-Nov-07 4:06
mveCPallini21-Nov-07 4:06 

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.