Click here to Skip to main content
15,920,896 members

Comments by TimGalant (Top 8 by date)

TimGalant 18-Oct-11 6:47am View    
Ok, I'am capable of working with structs and pointers to structs. But the problem is that I have a struct (MASTER) with a member that points to another struct (CHILD). I want to set a pointer to the first member of the array of MASTER structs in the CData class. Then I want the class to return a pointer to a value from for example the second struct (iNum = 1). With the normal data members of MASTER that's not a problem because the "distance" in the memory between the members is the same (the size of the MASTER struct). But the distance between the members of the CHILD structs in the memory is different (for example: the distance between the members of the CHILD structs in master[0] and master [2] is 0 because the structs are the same. The CHILD stuct of master[1] is somewhere else (unknown) in the memory because it was dynamically assigned.

So what I want is to return a pointer to for example master[0].pChild->iInt or master[1].pChild->iInt when I only have a pointer to the first member of the array of MASTER structs.

I hope I made clear what I want to do.
TimGalant 17-Oct-11 16:07pm View    
I mean that with a normal array you know "where" in the memory you can find the fourth, tentht, fiftieth etc. variable in the array if you have a pointer to the first variable of the array. With the structures I described above you don't know where in the memory you can find the members of the child structs.
TimGalant 17-Oct-11 15:21pm View    
But when I want to do it as I explained, can it be done and how? Cause the problem with the "alignment" in the memory will be the same, isn't it?
TimGalant 30-Sep-11 13:43pm View    
I've linked the dll as one of the projects in my solution. Normal classes export right, so I don't thinks it's the stuff "around" the coding.
TimGalant 29-Sep-11 12:29pm View    
*Philippe Mori:
As you can see, adding virtual destructors doesn't help. Or am I doing something wrong?
*Stefan_Lang: I've tried your solution, it seems to work with functions but I got the same error message with the contructors.