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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:18:31+00:00 2026-06-16T06:18:31+00:00

I have a code that has the following logic. g++ gives me the error

  • 0

I have a code that has the following logic. g++ gives me the error that I have not declared n in my iterator2. What could be wrong?

template <typename T> class List{
    template <typename TT> class Node;
    Node<T> *head;
    /* (...) */
    template <bool D> class iterator1{
        protected: Node<T> n;
        public: iterator1( Node<T> *nn ) { n = nn }
        /* (...) */
    };
    template <bool D> class iterator2 : public iterator1<D>{
        public:
        iterator2( Node<T> *nn ) : iterator1<D>( nn ) {}
        void fun( Node<T> *nn ) { n = nn; }
        /* (...) */
    };
};

EDIT :

I attach the actual header file. iterator1 would be iterable_frame and iterator2 – switchable_frame.

#ifndef LST_H
#define LST_H

template <typename T>
class List {
    public:
    template <typename TT> class Node;
    private:
    Node<T> *head; 
    public:
    List() { head = new Node<T>; }
    ~List() { empty_list(); delete head; }
    List( const List &l );

    inline bool is_empty() const { return head->next[0] == head; }
    void empty_list();

    template <bool DIM> class iterable_frame {
        protected:
        Node<T> *head; 
        Node<T> **caret;
        public:
        iterable_frame( const List &l ) { head = *(caret = &l.head); }
        iterable_frame( const iterable_frame &i ) { head = *(caret = i.caret); }
        ~iterable_frame() {}
    /* (...) - a few methods follow */
        template <bool _DIM> friend class supervised_frame;
    };
    template <bool DIM> class switchable_frame : public iterable_frame<DIM> {
        Node<T> *main_head;
        public:
        switchable_frame( const List& l ) : iterable_frame<DIM>(l) { main_head = head;     }
        inline bool next_frame() {
            caret = &head->next[!DIM];
            head = *caret;
            return head != main_head;
        }
    };
    template <bool DIM> class supervised_frame {
        iterable_frame<DIM> sentinels;
        iterable_frame<DIM> cells;
        public:
        supervised_frame( const List &l ) : sentinels(l), cells(l) {}
        ~supervised_frame() {}
    /* (...) - a few methods follow */
    };

    template <typename TT> class Node {
        unsigned index[2];
        TT num;
        Node<TT> *next[2];
        public:
        Node( unsigned x = 0, unsigned y = 0 ) {
            index[0]=x; index[1]=y;
            next[0] = this; next[1] = this;
        }
        Node( unsigned x, unsigned y, TT d ) {
            index[0]=x; index[1]=y;
            num=d;
            next[0] = this; next[1] = this;
        }
        Node( const Node &n ) {
            index[0] = n.index[0]; index[1] = n.index[1];
            num = n.num;
            next[0] = next[1] = this;
        }
        ~Node() {}
        friend class List;
    };
};
#include "List.cpp"

#endif

the exact error log is the following:

In file included from main.cpp:1:
List.h: In member function ‘bool List<T>::switchable_frame<DIM>::next_frame()’:
List.h:77: error: ‘caret’ was not declared in this scope
  • 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-16T06:18:32+00:00Added an answer on June 16, 2026 at 6:18 am

    Proper two-phase name look-up mandates that non-dependent names (i.e., names not depending on a template argument) are looked up in phase 1. At that point the base class members of a templatized base cannot be seen (because a specialization may yield a different layout). The fix is to make the names dependent. Change

    n = nn;
    

    to become

    this->n = nn;
    

    or, in the expanded example, change

    inline bool next_frame() {
        caret = &head->next[!DIM];
        head = *caret;
        return head != main_head;
    }
    

    to become

    inline bool next_frame() {
        this->caret = &head->next[!DIM];
        head = *this->caret;
        return head != main_head;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code that has @item.ID from razor: <a href=# id=deleteitem(@item.ID)>Delete</a> When
I have the following code that sets a background if user has uploaded to
I have the following rails code in a loop that has a link for
I have form on my page that has the following code <form class=form> ...
I have a problem that has been driving me batty. I have code that
I have a code that has some mpi api-dependent bits: #if MPIVERSION==1 ... #elif
I have this code that has one button that let's me choose an entry
ok so i have code that fundementally has this structure: firstly a main div
I have code in Java that has an outer loop and several nested loops.
I have a code base that has been used as an ASP.Net web application.

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.