Hi, I need to make an array of object pointers which is probably one of the easiest things to implement but I can't get my brain to wrap around this...
I create an object like this:
CMyObject * myObj = new CMyObject;
then I allocate some space in an array which is defined as a "void *", cast it to an array of pointers (CMyObject*)? and then assign the pointer to the new object to the end of the list:
declared as --> void * myList = NULL;
myNewList = realloc (myList, (numItems + 1) * sizeof (CMyObject *));
if (myNewList != NULL)
myList = myNewList;
CMyObject * objectPtrList = (CMyObject *)myList;
objectPtrList[numItems] = myObj;
Now, I'm kind of constrained as this code needs to adhere to the "void *" for storing the array and the memory must be allocated with malloc/realloc except for objects such as CMyObject...
The compiler I use complains at the assignment of objectPtrList[numItems]....