Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 629033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:42:04+00:00 2026-05-13T19:42:04+00:00

SingleList.h #include ListBase.h #include DataNode.h #include SingleListIterator.h namespace list { class SingleListIterator; class SingleList

  • 0

SingleList.h

#include "ListBase.h"
#include "DataNode.h"
#include "SingleListIterator.h"

namespace list
{
    class SingleListIterator;
    class SingleList : public ListBase
    {
        private:
            DataNode *head;
            DataNode *tail;
        public:
            SingleList();
            SingleList(const SingleList &obj);
            ~SingleList();
            void Flush(); //deletes all elements in the list
            void PushInFront(const int data); // **
            void Append(const int data); // **
            void DeleteLast();
            void DeleteFirst();
            int Delete(const int& data); // ** remove the first occurrence of data and return 1 otherwise 0
            const int& GetFirst() const; // **
            int& GetFirst(); // **
            const int& GetLast() const; // **
            int& GetLast(); // **
            void PrintList() const;
            const int IsEmpty() const;
    //        SingleList<T> &operator=(const SingleList<T>& obj) (**)
    //        const int operator==(const SingleList<T> &obj) const (**)
    //        const int operator!=(const SingleList<T> &obj) const (**)
    //        SingleList<T>& operator+(const SingleList<T> &obj) (**) // concatenates two lists
    //        operator int() // returns list size (**)
            friend class SingleListIterator; // ** ASK Changd it from Iterator
    };

SingleListIterator.h

#include "Iterator.h"
#include "SingleList.h"

namespace list
{
    class SingleList;
    class SingleListIterator: public Iterator
    {
        public:
                           // error here --> Forward declaration of 'const struct list::SingleList'
            SingleListIterator(const SingleList &list); // **
            SingleListIterator(const SingleListIterator &obj); // **
            virtual const int Current() const; // **
            virtual void Succ();
            virtual const int Terminate() const;
            virtual void rewind();
    //        T &operator++(int) (**)
    //        SingleListIterator<T>& operator=(const SingleListIterator<T>&obj) (**)
    };
            // error here --> Invalid use of incomplete type 'list::SingleList'
    SingleListIterator::SingleListIterator(const SingleList &list) : Iterator(list.head)
    {
    }

Errors indicated in code
Also what can I do in a case like this where there is mutual coupling between two header files ?????
Thaaaaanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:42:05+00:00Added an answer on May 13, 2026 at 7:42 pm

    You use forward declarations, but you anyway include the .h files recursively. The point of the forward declarations is that you don’t need to include the headers of the
    forward declared class, thereby breaking the mutual dependency.

    Also it should be enough to use a forward declaration for one of the classes, not for both of them.

    I would suggest the following structure:

    SingleListIterator.h:

    class SingleList;                // forward declaration
    class SingleListIterator {
       // Declarations, only using pointers/references to SingleList.
       // Definitions that need to know the structure of SingleList (like maybe
       // a constructor implementation) need to be done in the .cpp file.
    };
    

    SingleList.h:

    #include "SingleListIterator.h"  // include full declaration
    
    class SingleList {  
       // declarations
    };
    

    SingleListIterator.cpp:

    #include "SingleListIterator.h"
    #include "SingleList.h"           // include full declaration of the type
                                      // forward-declared in SingleListIterator.h
    
    // method definitions,...
    

    SingleList.h:

    #include "SingleList.h"            // include full declarations of everything
    
    // definitions
    

    This way there are no files that mutually include each other and all types are completely known in the implementation (.cpp) files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The g++ compiler prompt the following statement is wrong: template<typename Type> class SingleList{ public:
I am working with a 2 lists in a backend class. Each list is
I am trying to build a Linked list application using C++ programming language &
** I want one single list item to have fistname, last name and the
I need to display a single list, ordered by date which contains different types
I want to have some kind of single list that is initialized in a
Is it possible for setting more than one adapter to a single list? For
I am looking for advice about how to parse a single list, using two
How to create a Tuple and appending in to a single List ? a
I have a List<List> . I want to get a single List from that.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.