infoholic_anonymous
infoholic_anonymous

Reputation: 999

visibility of a nested class in an inherited class

The code I work on is roughly the following:

// List.h
template <typename T> class List{
    template <typename TT> class Node;
    Node<T> *head;
    /* (...) */
    template <bool D> class iterator1{
        protected: Node<T> this->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; }
        /* (...) */
    };
};

( should the exact code of the above one be needed, please refer to my previous question )

// Matrix.h
#include "List.h"
template <typename T>
class Matrix : List<T> {
    /* (...) - some fields */
    class element {
        supervised_frame<1> *source; // line#15
        /* (...) - some methods */
    };
};

I get the following error in g++:

 In file included from main.cpp:2:
 Matrix.h:15: error: ISO C++ forbids declaration of ‘supervised_frame’ with no type
 Matrix.h:15: error: expected ‘;’ before ‘<’ token

Upvotes: 1

Views: 142

Answers (2)

Alexander Chertov
Alexander Chertov

Reputation: 2108

I believe Matrix<T>::element class is not related to class List<T>. So I think you should have typename List<T>::template supervised_frame<1>.

Upvotes: 2

Karthik T
Karthik T

Reputation: 31952

Similar to your previous problem - Use typename List<T>::supervised_frame<1> *source; This is because supervised_frame<1> is a dependant type, i.e it is dependant on the template parameter T

Upvotes: 2

Related Questions