c++ - No member function declaration in class template -
i have template class named skiplist
, nested class named iterator
in it.
skiplist
follows following definition:
template <typename key_t, typename mapped_t, size_t maxlevel = 5> class skiplist { typedef std::pair<key_t, mapped_t> valuetype; public: class iterator { iterator (const iterator &); iterator &operator=(const iterator &); iterator &operator++(); iterator operator++(int); iterator &operator--(); iterator operator--(int); private: //some members };
iterator
has copy constructor , declaring outside class after definition this:
template <typename key_t, typename mapped_t,size_t maxlevel> skiplist<key_t,mapped_t,maxlevel>::iterator(const skiplist<key_t,mapped_t,maxlevel>::iterator &that)
but following error:
skiplist.cpp:134:100: error: iso c++ forbids declaration of ‘iterator’ no type [-fpermissive] skiplist.cpp:134:100: error: no ‘int skiplist<key_t, mapped_t, maxlevel>::iterator(const skiplist<key_t, mapped_t, maxlevel>::iterator&)’ member function declared in class ‘skiplist<key_t, mapped_t, maxlevel>’
what wrong?
try this:
template <typename key_t, typename mapped_t,size_t maxlevel> skiplist<key_t,mapped_t,maxlevel>::iterator::iterator (const skiplist<key_t,mapped_t,maxlevel>::iterator &that) { ...
you forgot qualify iterator copy constructor skiplist::iterator::iterator
, looking skiplist member function called skiplist::iterator
, hence error "no member function".
Comments
Post a Comment