Thread: does a base class include the header files of its subclasses

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    118

    does a base class include the header files of its subclasses

    does a base class need to include the header files of its subclasses

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by sigur47
    does a base class need to include the header files of its subclasses
    A base class does not include any header files. As for the file containing the definition of the base class: it probably should not be including any header files that contain the definition of any subclass of that base class.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    118
    Quote Originally Posted by laserlight View Post
    A base class does not include any header files. As for the file containing the definition of the base class: it probably should not be including any header files that contain the definition of any subclass of that base class.
    Thank you

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I would go as far as to say, if you need to include the header files of subclasses in your base class, then you most likely have a broken implementation somewhere.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. where to include header files?
    By kaos_frack in forum C++ Programming
    Replies: 6
    Last Post: 12-30-2008, 03:09 PM
  2. Using #include and header files
    By _izua_ in forum C++ Programming
    Replies: 3
    Last Post: 08-12-2007, 09:08 PM
  3. Header files - where to include
    By C+/- in forum C++ Programming
    Replies: 5
    Last Post: 01-13-2007, 10:45 AM
  4. include library header in header files
    By Raison in forum C++ Programming
    Replies: 6
    Last Post: 09-27-2004, 02:50 AM
  5. Necessary to include header files?
    By Nutshell in forum C Programming
    Replies: 5
    Last Post: 01-22-2002, 04:16 AM