0
我有一個名爲SkipList
的模板類和一個名爲Iterator
的嵌套類。類模板中沒有成員函數聲明
SkipList
遵循以下定義:
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
有一個拷貝構造函數,我的定義是這樣後聲明它的類外:
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)
但我得到以下錯誤:
SkipList.cpp:134:100: error: ISO C++ forbids declaration of ‘Iterator’ with 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>’
出了什麼問題?
[SSCCE](http://sscce.org)怎麼樣? – 2013-04-20 00:03:28
@AndyProwl我改變了這個問題 – footy 2013-04-20 00:06:00