I would like to create a class Word
in which there is a word. I will have a class instance for almost every word in the dictionary (so many) - and no, I cannot use the tree structure to store this for my specific application. Of course, the size of the lines can change, and I do not want to kill memory. I would like to do this in a class like this:
class Word {
public:
...
private:
int len;
LetterData letters[];
};
And then dynamically highlight Word using:
Word *pNewWord = malloc(sizeof(Word)+sizeof(LetterData)*len);
I understand that this is not very C ++ 'ish. So my questions are: firstly, is there a better way to do this, and if not, will it cause problems? The word does not inherit any other type of class (I am pretty sure that inheritance will kill this ...).
: - , ...