CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2009
    Posts
    8

    Question Linked List help

    Hi,
    I have class A which holds a linked list of a class B. How do I get each object in B to hold a pointer to point back to its respective A object parent? I get an error when trying to include A.h in B.h; including B.h inside A.h works fine.

    Noel

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Linked List help

    You can forward declare A in the header file of B, e.g.,
    Code:
    class A;
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Join Date
    Jul 2009
    Posts
    8

    Re: Linked List help

    Thanks, do I do that with or without including A.h inside B.h

    Noel

  4. #4
    Join Date
    Jul 2009
    Posts
    8

    Re: Linked List help

    Without the header, I tested.

    Thanks,
    Noel

  5. #5
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Linked List help

    Without including A.h in B.h.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured