I have a structure that looks roughly like this:
struct myStruct {
short vectLen;
char sevs[1];// actually vectLen long
};
That layout is mine and not absolutely cast in stone, but it is what makes sense for a particular interface. I can certainly tweak the declaration: make it a union of what I have now plus something else, for example.
What would be the best C++ coding practice for allocating a new instance of myStruct?
I can obviously do something like (just keying this in; may have a syntax error)
myStruct *ms = reinterpret_cast<myStruct *>(new char[desired_vector_length+sizeof(short)]);
Is there a better way?
How would I delete it? I would assume that delete ms; is risky and better would be something like
delete[] reinterpret_cast<char *>(ms);
Thanks,
Charles