Thread: Strange problem with classes in header files

  1. #1
    Registered User samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Newport
    Posts
    382

    Strange problem with classes in header files

    I'm currently working on a game project and I've run into a strange problem. There is a class (called 'body') that is extended by classes 'missile' and 'robot'. Each class is in its own header file and cpp file - all was working fine until all of a sudden the project stopped compiling with the error "body baseclass undefined", even though the body.h file is included in all relevant places.

    I've checked this header file and all syntax seems perfectly correct (further evidenced by the fact that it compiles if I cut and paste the code from the header file into the relevant places).

    And, as I say, this error just seemed to come out of nowhere - I had made no major changes recently when this started happening and the project was compiling and executing perfectly well before.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Well, say A.h includes body.h, does body.h include A.h?
    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.

  3. #3
    Registered User samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Newport
    Posts
    382
    Yeah, that's what it was! Doh!

    Fixed with a few forward declarations.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Header files in .h
    By swgh in forum C++ Programming
    Replies: 5
    Last Post: 05-29-2008, 08:58 AM
  2. Header Files
    By Volair in forum C Programming
    Replies: 2
    Last Post: 12-09-2005, 10:51 AM
  3. Header Files and Classes.
    By Lithorien in forum C++ Programming
    Replies: 10
    Last Post: 08-13-2004, 12:10 PM
  4. Header files
    By borland_man in forum C++ Programming
    Replies: 14
    Last Post: 02-22-2002, 04:30 AM
  5. doin' classes in header files?
    By face_master in forum C++ Programming
    Replies: 9
    Last Post: 11-14-2001, 03:56 AM