Including header file in a header file

closed account (SwTk92yv)
Suppose there are two classes that I wrote - a base class and a derived one - in separate header/cpp files:

BaseClass.h:
class BaseClass {....}

Derived.h:
class Derived : BaseClass {....}

BaseClass is not dependent on any #includes.

Each time I use and #include a Derived class, I need to #include the BaseClass.h. Is it alright to #include BaseClass.h in Derived.h, considering BaseClass does not #include anything?
Not only is it alright, but you absolutely should do it.

See section 5 of this article:

http://www.cplusplus.com/forum/articles/10627/#msg49679
Yes, all files should be able to compile on their own, so BaseClass.h have to include Derived.h.
Last edited on
@Peter87 are you sure you don't mean the other way around?
Yes, of course I mean the other way around. Stupid me!
Topic archived. No new replies allowed.