I am a beginner at C++. I need to develop a class called WORD. I am asked to define a class called character. Is the correct syntax here:
class WORD
{
public:
class character
{
public:
char symbol;
character *next;
};
};
Class character has two fields: a char field called symbol, and a pointer field called next. Each node(character)in the list will contain one symbol of a word.
Well, you missed a ; after character class definition, but apart from that it is fine. Note that the only effect of putting character inside WORD is that you'll have to refer to it as WORD::character, outside the WORD class. You still need to say that WORD has a character member.
Re what hamsterman said: It is up to you if you want to make "character" an inner class to "WORD", but there is *probably* no good reason to do so unless you want "character" only to be accessible in "WORD" context. But that isn't even true right now because you have made "character" a public class.