Simple question on pointers and classes that hold pointers
Posted on 2004-04-17
I'm just confusing myself here, but I have a class CImageResource which I basically want to be a representation of a bitmap (I'm using gdi+) with a few extra methods and variables.
I have a dynamic array of these classes, so that's a pointer to the first element right?
Now, my question is... how do I want this to look? If we just talk about the class 'holding' a bitmap, should it be a Bitmap, pointer to bitmap, or what? Because basically, I need the array initialised, then a class loads a bitmap from a file, and sets an element in the array's bitmap to that one. The class that sets this bitmap, later needs to access it again to draw it. With a dynamic array like this (I've got CImageResource *pics = new CImageResource[numberOfElements]; and nothing in the CImageResource constructor) do I need to separately initialise each element to something, or for that matter the bitmaps in each element?
I can get it to compile, but I get access violation errors on debugging,