does a base class include the header files of its subclasses

This is a discussion on does a base class include the header files of its subclasses within the C++ Programming forums, part of the General Programming Boards category; does a base class need to 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
    22,304
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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
    Posts
    23,025
    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, 10: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, 03:50 AM
  5. Necessary to include header files?
    By Nutshell in forum C Programming
    Replies: 5
    Last Post: 01-22-2002, 04:16 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21