Thread: C++ error.. A desperate attempt for help..

Results 1 to 8 of 8
  1. #1 C++ error.. A desperate attempt for help.. 
    Registered Member
    Join Date
    Aug 2011
    Posts
    230
    Thanks given
    2
    Thanks received
    22
    Rep Power
    45
    For a university project we are creating game scenes using the Irrlicht game engine in c++.. I'm finding it really difficult learning the basics of the language as its so different to everything else i've learnt..

    Here is an error I've been trying to fix for about 2 hours now.. can anyone please help


    http://gyazo.com/7da909fcc1c9b5d2fbbeb7934b7b84b7


    http://gyazo.com/466d8e3cd2b53a6aad4370c66c1fa135


    http://gyazo.com/9532056bb50036d39a053d790152792c

    If anyone could explain why i'm getting this error it would help so much.
    Thanks for your time

    Edit: trying to get images embedded.
    Reply With Quote  
     

  2. #2  
    q.q


    Join Date
    Dec 2010
    Posts
    6,519
    Thanks given
    1,072
    Thanks received
    3,535
    Rep Power
    4752
    well c++ compiler is annoying as heck and can't be trusted

    you have imported it though ?
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Aug 2011
    Posts
    230
    Thanks given
    2
    Thanks received
    22
    Rep Power
    45
    Erm.. I've had problems with importing in the past with this same error..


    at the moment all of the include statements are in the stdafx.h file and then that is included into these classes.

    It does really seem like bullshit to me.. the object is defined so why is it saying its not..


    I'm still trying to fix this.. this is the new error i'm getting



    again makes no sense.. missing ";" apparently
    Reply With Quote  
     

  4. #4  
    q.q


    Join Date
    Dec 2010
    Posts
    6,519
    Thanks given
    1,072
    Thanks received
    3,535
    Rep Power
    4752
    have you included the KeyEventReceiver in Client.h?

    is what i meant ot ask

    either way show your includes for client.h
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Aug 2011
    Posts
    230
    Thanks given
    2
    Thanks received
    22
    Rep Power
    45
    Okay.. so I've since turned off precompiled headers..

    My KeyEventReciever.h now has:

    #include <irrlicht.h>
    #include "Client.h"

    and my Client.h has:

    #include <irrlicht.h>
    #include "KeyEventReceiver.h"

    heres my error message:
    Reply With Quote  
     

  6. #6  
    q.q


    Join Date
    Dec 2010
    Posts
    6,519
    Thanks given
    1,072
    Thanks received
    3,535
    Rep Power
    4752
    you'll run into a circular dependence issues when you have classes including eachother

    try importing the class using

    Code:
    class KeyEventReceiver;
    above the class decleration instead of the include
    or just the client include from keyeventdeceiver, not needed?
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Aug 2011
    Posts
    230
    Thanks given
    2
    Thanks received
    22
    Rep Power
    45
    I'm currently having this error now..



    Anyone have advice =( ?
    Reply With Quote  
     

  8. #8  
    Human

    Only's Avatar
    Join Date
    Aug 2008
    Posts
    1,108
    Thanks given
    1
    Thanks received
    18
    Rep Power
    116
    You need to forward declare in both classes that are co-dependent. If that doesn't work, you should move the co-dependent class inclusion into the definitions file (.cpp). So you'll have something like this:

    Code:
    //A.h
    class B;
    class A {
        B* b;
        public:
            void setB(B* b);
    };
    
    
    //B.h
    class A;
    class B {
        A* a;
        public:
            void setA(A* a);
    };
    
    //A.cpp
    #include "A.h"
    #include "B.h"
    
    void A::setB(B* b) {
        this->b = b;
    }
    
    
    //B.cpp
    #include "B.h"
    #include "A.h"
    
    void B::setA(A* a) {
        this->a = a;
    }
    Happy coding!
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [PI] Thread-5 Error! (Will give sex for help!)
    By Owner of Flamescape in forum Help
    Replies: 3
    Last Post: 04-27-2011, 06:09 AM
  2. Replies: 1
    Last Post: 08-31-2010, 03:29 AM
  3. Replies: 4
    Last Post: 12-01-2009, 10:12 PM
  4. error :S giving rep++ for help
    By Darkie in forum Help
    Replies: 2
    Last Post: 03-15-2009, 02:26 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •