Reputation: 328
I'm currently making a small little parser for this simple GUI scripting language that I'm creating. Everything works fine, but I need to know if it's possible to do this:
Parser.hpp:
class Parser
{
public:
enum class LineType;
}
GUIParser.hpp:
class GUIParser : public Parser
{
public:
enum class LineType
{
BACKGROUND,
BUTTON,
LABEL,
RADIOBOX,
COMMENT
};
}
This gives me an error, but if it's possible then what syntactical error am I making?
Thanks for any and all help!
Upvotes: 0
Views: 68
Reputation: 49261
That's declaring that there's an enum called LineType
inside Parser
or: Parser::LineType
.
In the derived class you have an enum called LineType
, and its full 'name' will be: GUIParser::LineType
.
So, because you can't predict the name of the derived class, you can't forward declare what it will contain.
That's the logic behind it, the simpler answer is: no, it's not in the standard.
Upvotes: 5