Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

C++ compilation problems

  • 15-03-2001 2:50am
    #1
    Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭


    I have two classes (ObjectList and ObjectNode) which both refer to each other (ie ObjectList contains an ObjectNode pointer and vice versa). However when I try to compile the program I can't get these two classes to compile because they're both looking for each other (I think).

    Am I [not] doing something stupid?


Comments

  • Subscribers Posts: 1,911 ✭✭✭Draco


    Why does your ObjectNode refer to ObjectList?
    Is it a linked list you're writing?
    What you need to do is make a forward declaration of the classes:

    //forward declaration of ObjectNode
    class ObjectNode;

    class ObjectList{
    public:
    blah blah blah

    };

    If you are make a linked list, you shouldn't have to refer to ObjectList in the ObjectNode class.

    Draco


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    Well it's a linked list, but every node contains a sub-list of nodes, sort of a tree.

    I put in forward declarations of the other class in both header files which seems to have cleared up a lot of errors, but now the problem is that even with the declarations, when any methods in those classes are called they're not known.
    frown.gif



  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    I had an inlined function in the header which was calling a function of the other class, so I removed this and put it in the .cpp file and now it's compiling fine biggrin.gif

    Nice one Draco, thanks alot.


  • Registered Users, Registered Users 2 Posts: 932 ✭✭✭yossarin


    Jazz it sounds like you need to come into town today for our meeting with Louis


    wink.gif



  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    yeah yeah yeah I'll be there


  • Advertisement
Advertisement