Strange problem with classes in header files

This is a discussion on Strange problem with classes in header files within the C++ Programming forums, part of the General Programming Boards category; I'm currently working on a game project and I've run into a strange problem. There is a class (called 'body') ...

  1. #1
    Budding Synth Programmer samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Trefforest
    Posts
    368

    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をこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    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
    Budding Synth Programmer samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Trefforest
    Posts
    368
    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, 09: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, 03:30 AM
  5. doin' classes in header files?
    By face_master in forum C++ Programming
    Replies: 9
    Last Post: 11-14-2001, 02:56 AM

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