In an effort to get up to date with C to C++, I've ran into a problem.
I am using an 3rd-party library that returns the raw amount of bytes ot
allocate for a structure that it also uses. So I do something as
follows:
FeaturesStruct* pFeatures = (FeaturesStruct *) new BYTE[StructSize];
This works fine with the API for all intents and purposes.
However, when changing the C style cast to a static_cast, I cannot
compile it.
Using VC++ I get:
Error 1 error C2440: 'static_cast' : cannot convert from 'BYTE *' to
'FeaturesStruct *'
I was curious as to what the correct way to allocate the structure
would be in this case would be, or if I'm just stuck using C style
casts because of the way the library functions?
Thanks,
Josh McFarlane
I am using an 3rd-party library that returns the raw amount of bytes ot
allocate for a structure that it also uses. So I do something as
follows:
FeaturesStruct* pFeatures = (FeaturesStruct *) new BYTE[StructSize];
This works fine with the API for all intents and purposes.
However, when changing the C style cast to a static_cast, I cannot
compile it.
Using VC++ I get:
Error 1 error C2440: 'static_cast' : cannot convert from 'BYTE *' to
'FeaturesStruct *'
I was curious as to what the correct way to allocate the structure
would be in this case would be, or if I'm just stuck using C style
casts because of the way the library functions?
Thanks,
Josh McFarlane
Comment