How to creat two dimension array in the heap

falcon eyes's Avatar
Go4Expert Member
Hi All
I'm using MS-VStudio 2005and want to creat two dimension array in the heap(free store )
but when i write the code
float *pFloat;
pFloat=new float[3][5];

and compile the profram i got the following error

error C2440: '=' : cannot convert from 'float (*)[5]' to 'float *'
1>Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast


so could someone please tell me what's wrong in my code
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
You have posted it as an Article under the Article / Source code section. I have moved it to the Queries and Discussion forum. Please take care that you don't repeatedly post the query as an article.
0
falcon eyes's Avatar
Go4Expert Member
Thanks and sorry
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
Code:
    float (*pFloat)[5] = new float [3][5];
0
falcon eyes's Avatar
Go4Expert Member
Thanks
i will try it and if i have any notes i will post it
0
falcon eyes's Avatar
Go4Expert Member
Please DaWei
when i tryed the code u suggested
float (*pFloat)[5] = new float [3][5];
in my code i got this error
error C2040: 'pFloat' : 'float (*)[5]' differs in levels of indirection from 'float *'
So what's wrong do u have any suggestions[I]
0
tailhook123's Avatar, Join Date: May 2007
Go4Expert Member
http://support.microsoft.com/kb/104639 should cover all the problems involved and the workarounds.
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
Works for me. Perhaps you have defined it otherwise, elsewhere.