ast_expression header file not included in other ast header files. #75
-
I was reading the ast hpp files and found out that apart from ast_functions.hpp, none of the other hpp files included the header #include "ast_expression.hpp" despite inheriting from the class Expression. May I ask why is it not required? From my understanding, we need to include the header file of the parent class in the inherited class's headerfile. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I do agree that it's not the best style, and I actually hadn't noticed until know. You are right that for the inheritance, it is actually necessary to have the full declaration of the class. However, the reason it still compiles, is because you are only ever including |
Beta Was this translation helpful? Give feedback.
I do agree that it's not the best style, and I actually hadn't noticed until know. You are right that for the inheritance, it is actually necessary to have the full declaration of the class.
However, the reason it still compiles, is because you are only ever including
ast.hpp
everywhere else, which first includesast_expression.hpp
, and so all following header files will haveExpression
available. However, this does mean that if you just want to includeast_primitives.hpp
on it's own in a separate file, you would get a compile error, because you would have to manually put#include "ast_expression.hpp
before that, which isn't great. So it's definitely better to put#include "ast_expression…