#includes (C++)

Discussion in 'Software' started by ministe2003, Mar 31, 2008.

  1. ministe2003

    ministe2003 Private E-2

    Hi all,

    I'm trying to #include a class in several different classes, the problem is because these classes are all included into another, I get redefinition errors.

    What I mean is:

    Game.h #includes:
    Material.h,
    Terrain.h,
    ParticleSystem.h

    Terrain.h and ParticleSystem.h also both #include Material.h

    Because of this I'm getting redefinition errors, how can I fix this so that all three can access Material? I know it's probably simple but I cant fix it.

    Thanks!

    Steven
     
  2. Assembler

    Assembler Private E-2

    you may have to include all the header files individually.
    instead of doing

    Code:
    #include <Game.h>
    
    you may have to do:

    Code:
    #include <Material.h>
    #include <Terrain.h>
    #include <ParticleSystem.h>
    #include <whatever else is in Game.h>
    
    know what i mean?
     
  3. Wyatt_Earp

    Wyatt_Earp MajorGeek

  4. ministe2003

    ministe2003 Private E-2

    Thanks Wyatt Earp, that's just the job!

    Steven
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds