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 8493419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:00:10+00:00 2026-06-10T23:00:10+00:00

Hi I am trying to implement a linked list using templates and ADT. At

  • 0

Hi I am trying to implement a linked list using templates and ADT. At the moment I have two classes. One is an iterator for linked list and the other is the base class for linked lists that I will use to derive linked list classes from.

When trying to implement two functions that will give me an iterator at the start and end of the list respectivly I get compile error saying “ISO C++ forbids declaration of ‘linkedListIterator’ with no type”

Here is the code for the definition of the iterator:

#ifndef LINKEDLISTITERATOR_H
#define LINKEDLISTITERATOR_H

#include <stddef.h> //for NULL
#include "nodetype.h"
#include "linkedlisttype.h"


template <class Type>
class linkedListIterator
{
public:
    linkedListIterator();

    linkedListIterator(nodeType<Type> *ptr);

    Type operator*();

    linkedListIterator<Type> operator++();

    bool operator==(const linkedListIterator<Type>& right) const;

    bool operator!=(const linkedListIterator<Type>& right) const;

private:
    nodeType<Type> *current; 
};

#endif // LINKEDLISTITERATOR_H

Here is the code for the definition of the node Type

#ifndef NODETYPE_H_INCLUDED
#define NODETYPE_H_INCLUDED

//Definition of the node
template <class Type>
struct nodeType
{
    Type info;
    nodeType<Type> *link;
};

#endif // NODETYPE_H_INCLUDED

Here is the definition of the linkedlist base class:

#ifndef LINKEDLISTTYPE_H
#define LINKEDLISTTYPE_H

#include "nodetype.h"
#include "linkedlistiterator.h"

//Definition of linked list
template <class Type>
class linkedListType
{
public:
    const linkedListType<Type>& operator=
    (const linkedListType<Type>&);

    void initializeList();

    bool isEmptyList() const;

    void print() const;

    int length() const;

    void destroyList();

    Type front() const;

    Type back() const;

    virtual bool search(const Type& searchItem) const = 0;

    virtual void insertFirst(const Type& newItem) = 0;

    virtual void insertLast(const Type& newItem) = 0;

    virtual void deleteNode(const Type& deleteItem) = 0;

    // this is where the error comes    
    linkedListIterator<Type> begin();

    // and here as well
    linkedListIterator<Type> end();

    linkedListType();

    linkedListType(const linkedListType<Type>& otherList);

    ~linkedListType();

protected:
    int count; 
    nodeType<Type> *first; 
    nodeType<Type> *last; 

private:
    void copyList(const linkedListType<Type>& otherList);
};

#endif // LINKEDLISTTYPE_H

I am new to templates and ADT so trying to wrap my mind around this. Any help will be most appreciated please.

  • 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-06-10T23:00:12+00:00Added an answer on June 10, 2026 at 11:00 pm

    You have two headers which each try to include each other. The result is that, if you #include "linkedlistiterator.h", the definition of linkedListType appears before that of linkedListIterator; hence the error due to linkedListIterator not being declared at that point.

    In this case, it looks like the iterator type does not depend on the list type at all, so you can simply remove the #include "linkedlistlype.h" from "linkedlistiterator.h".

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

Sidebar

Related Questions

I'm having trouble trying to implement a linked List without using classes(we're not there
I am trying to implement a linked-list in C++. Currently, I have the following
I have been trying to implement my own linked list class for didactic purposes.
I am trying to implement a linked list using following code, I got segment
I am trying to implement a simple linked list using c++. I am probably
I'm trying to implement doubly-linked list in c++ and right now I'm adding iterator
I am trying to implement the linked list data structure using java, it works
I have been trying to implement XOR linked list and its operations but I
I'm trying to implement a linked list but get an error when compiling: intSLLst.cpp:38:
Im trying to implement a destructor for the objects of linked-list Iv created. I

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.