Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Class Redefenition Problems

Class Redefenition Problems

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++game-devdata-structures
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CoffeeAddict19
    wrote on last edited by
    #1

    I'm having problems with class redefenition errors (4 of them, plus 93 other errors about not being able to find class defenitions). Include guards are in place in every file but I'm still getting errors becuase the classes are dependant on one another and I can't figure out a way for all the dependancies to be satisfied and still not get any class redefenitions. The relevant files: game_main.cpp requires stdafx.h and game_operations.h (class CGameWin) tree_operations.h (class TreeOperations) requires stdafx.h GameDialog.h (class GameOptionsDialog) requires stdafx.h, and game_interface.h (class CGameWin) game_operations.h (class GameOperations) requires stdafx.h, game_interface.h (class CGameWin), and tree_operations.h (class TreeOperations) game_interface.h (class CGameWin) requires stdafx.h, GameDialog.h (class GameOptionsDialog), and game_operations.h (class GameOperations) As you can see, I need class CGameWin in both GameDialog.h and game_operations.h, which is a problem since game_interface.h needs GameDialog.h. It makes a loop. I can post the header files if you need me to, but it will take up a lot of space. Please help me out with this. :sigh:

    PJ ArendsP 1 Reply Last reply
    0
    • C CoffeeAddict19

      I'm having problems with class redefenition errors (4 of them, plus 93 other errors about not being able to find class defenitions). Include guards are in place in every file but I'm still getting errors becuase the classes are dependant on one another and I can't figure out a way for all the dependancies to be satisfied and still not get any class redefenitions. The relevant files: game_main.cpp requires stdafx.h and game_operations.h (class CGameWin) tree_operations.h (class TreeOperations) requires stdafx.h GameDialog.h (class GameOptionsDialog) requires stdafx.h, and game_interface.h (class CGameWin) game_operations.h (class GameOperations) requires stdafx.h, game_interface.h (class CGameWin), and tree_operations.h (class TreeOperations) game_interface.h (class CGameWin) requires stdafx.h, GameDialog.h (class GameOptionsDialog), and game_operations.h (class GameOperations) As you can see, I need class CGameWin in both GameDialog.h and game_operations.h, which is a problem since game_interface.h needs GameDialog.h. It makes a loop. I can post the header files if you need me to, but it will take up a lot of space. Please help me out with this. :sigh:

      PJ ArendsP Offline
      PJ ArendsP Offline
      PJ Arends
      wrote on last edited by
      #2

      Header files should never need stdafx.h. Stdafx.h must be the first file included in all your cpp files. Can you do a simple forward declaration in one of your header files and then include the actual header file in your cpp file?


      You may be right
      I may be crazy
      -- Billy Joel --

      Within you lies the power for good, use it!!!

      Within you lies the power for good; Use it!

      C 1 Reply Last reply
      0
      • PJ ArendsP PJ Arends

        Header files should never need stdafx.h. Stdafx.h must be the first file included in all your cpp files. Can you do a simple forward declaration in one of your header files and then include the actual header file in your cpp file?


        You may be right
        I may be crazy
        -- Billy Joel --

        Within you lies the power for good, use it!!!

        C Offline
        C Offline
        CoffeeAddict19
        wrote on last edited by
        #3

        I got it running. Thanks for the help.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups