1

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
Community
  • 1
  • 1
infoholic_anonymous
  • 969
  • 3
  • 12
  • 34
  • There's not enough code here to pinpoint an error. At a guess, however, you need to forward declare `supervised_frame`. – Yuushi Dec 13 '12 at 06:01
  • @Yuushi please refer to the link provided. There is List.h which I include in the above code and where supervised_frame is defined. – infoholic_anonymous Dec 13 '12 at 06:03
  • 1
    Whoever upvoted this question, why? It's completely nonsensical as-is. @infoholic_anonymous : Please see http://sscce.org/; making the people you want help from do all the work isn't productive. – ildjarn Dec 13 '12 at 06:03
  • @ildjarn The title makes it perfectly clear in my opinion. He really should have included a short definition of `List` though. – Pubby Dec 13 '12 at 06:07
  • @Pubby Thanks for the remark, I've done what you've suggested – infoholic_anonymous Dec 13 '12 at 06:25

2 Answers2

2

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>.

Alexander Chertov
  • 2,070
  • 13
  • 16
  • @infoholic_anonymous,OK, then I think it needs to be `typename List::template supervised_frame<1>` . This is to let the compiler know that the 2nd "<" is a bracket and not a less-than. – Alexander Chertov Dec 13 '12 at 06:16
2

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

Karthik T
  • 31,456
  • 5
  • 68
  • 87