Got a quick C++ question here, tl;dr version is: Got a struct with some objects, creating a new array of objects, using heapalloc (which I thought would be similar to initialising them all manually, I can access/change VarB and VarC but whatever I try to do with VarA causes exception nightmare)
Long version: I've got a struct;
typedef struct ThreadSocketData
{
list<SOCKET*> VarA;
unsigned int VarB;
unsigned int VarC;
} THREADSOCKETDATA, *PTHREADSOCKETDATA;
I'm allocating it as a global and in a function as;
Question
n_K
Got a quick C++ question here, tl;dr version is: Got a struct with some objects, creating a new array of objects, using heapalloc (which I thought would be similar to initialising them all manually, I can access/change VarB and VarC but whatever I try to do with VarA causes exception nightmare)
Long version: I've got a struct;
I'm allocating it as a global and in a function as;
Then I try to use it like so;
I've tried created it alternatively and like so and it seems to work fine;
So why does the second way work but the first doesn't fully work? Surely using heapalloc would have the same effect as manually allocating it all?
Link to comment
Share on other sites
10 answers to this question
Recommended Posts