#### Archived

This topic is now archived and is closed to further replies.

# why doesnt this memory allocation work ?

## Recommended Posts

ncsu121978    1344
  CProcessControlBlock** currentProcessOnDevice; currentProcessOnDevice = new (CProcessControlBlock*)[args->numDevices]; 
error is C:\Documents and Settings\Administrator\My Documents\classes\csc246\program3\CSimulatedOS.cpp(27) : error C2143: syntax error : missing '';'' before ''['' this is for a class but it isnt like i am asking you how to program stuff. now that i think about it i dont believe i have ever got dynamic 2d arrays to work in MSVC 6.0 what this is doing is creating an array of pointers. it does know what type CProcessControlBlock is because I am including the header for that class and it would say unndefined type or something if it didnt know the type. "I pity the fool, thug, or soul who tries to take over the world, then goes home crying to his momma." - Mr. T

##### Share on other sites
Anon Mike    1098
Probably the paranthesis are confusing the compiler. It might think you''re trying to use placement new. Try leaving them out. e.g.

currentProcessOnDevice = new CProcessControlBlock*[args->numDevices];

-Mike

##### Share on other sites
Arild Fines    968
  CProcessControlBlock** currentProcessOnDevice;currentProcessOnDevice = new CProcessControlBlock*[args->Devices];

Dunno why really...maybe the compiler parses it as a cast?

Although...
  vector< vector< CProcessOnDevice > > currentProcessOnDevice;

_might_ be preferrable.

"I contend that we are both atheists. I just believe in one fewer god than you do. When you understand why you dismiss all the other possible gods, you will understand why I dismiss yours." - - Stephen Roberts