Gmt
Gmt

Reputation: 569

template typename instantiation error

template <typename List>
class list_base {
    typedef typename List::node node;

};


template <typename T, typename Allocator = allocator<T>>
class list: private list_base<list<T, Allocator>> {
    typedef Allocator allocator_type;

    class node {

    };
};

When I instantiate list<int> x it gives me an error:

../src/Console.cpp: In instantiation of ‘class list_base<list<int> >’:
../src/Console.cpp:27:7:   required from ‘class list<int>’
../src/Console.cpp:36:12:   required from here
../src/Console.cpp:21:30: error: no type named ‘node’ in ‘class list<int>’

Type node clearly is defined. What happens here ?

Upvotes: 1

Views: 78

Answers (1)

R Sahu
R Sahu

Reputation: 206567

Question:

Type node clearly is defined. What happens here ?

list is not completely defined when the base class is instantiated.

Upvotes: 2

Related Questions