Recommended Posts

Hi, I''m using the CDisplay and CSurface classes from ddutil.h for my graphics. The default way to interact with these two classes is to use pointers CDisplay*, CSurface* to call their functions like:
CSurface * someDisplay;
initialize stuff..
use like this: someDisplay->Destroy();
Ok now what I want to do is create a class that describes a game object in my game. I want this class to store CSurface(bitmaps) pointers in a dynamic array because I want to be able to add and remove frames whenever I want.
So in my class header private section I have a variable
CSurface** objectSurfaces; (Im thinking this is what I need because basically I want a pointer for the dynamic array, and then each element of the array will be pointers themselves.
However in my constructor when I want to initialize a dynamic array, then create the surface with this code:
objectSurfaces = new CSurface[numFrames];
mainDisplay->CreateSurfaceFromBitmap((objectSurfaces[currFrame]),fileName,surfaceWidth,surfaceHeight);
The first parameter to CreateSurfaceFromBitmap is usually &objectSurfaces if objectSurfaces was just a pointer to a CSurface.
I get the following errors (there are more as a result of the constructor not working but I focused most important ones)
--------------------Configuration: Engine - Win32 Debug--------------------
Compiling...
BomberBlitterObject.cpp
bomberblitterobject.cpp(55) : error C2440: ''='' : cannot convert from ''class CSurface *'' to ''class CSurface ** ''
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
bomberblitterobject.cpp(56) : error C2664: ''CreateSurfaceFromBitmap'' : cannot convert parameter 1 from ''class CSurface *'' to ''class CSurface ** ''
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
bomberblitterobject.cpp(92) : error C2664: ''long __thiscall CDisplay::Blt(unsigned long,unsigned long,struct IDirectDrawSurface7 *,struct tagRECT *,unsigned long)
'' : cannot convert parameter 3 from ''class CSurface ** '' to ''struct IDirectDrawSurface7 *''
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
engine.cpp
So in otherwords I need help with an array to hold a bunch of pointers of specific type. I have created 2d dynamic arrays for another part of my game and they work fine with the int** map pointer.
Thanks!