ネストされた iterator クラスと const_iterator クラスが内部にある二重リンク リスト クラスに関するコンパイルで問題が発生しています。
私はテンプレート構文を使用するのが初めてで、少し悪夢のようになっています。現在、各関数でエラーが発生し、最後にリンカー エラーが発生しているようです。これにより、ヘッダーに問題があるか、ヘッダーが含まれているか、関数のシグネチャに関係があるように感じます。
私のヘッダーのサンプルは次のとおりです。
class const_iterator {
friend RecentList;
Node* curr_;
const_iterator(Node* p);
public:
const_iterator();
const_iterator operator++() const;
対応する実装は次のとおりです。
template <typename T>
RecentList<T>::const_iterator::const_iterator(){
curr_=nullptr;
}
template <typename T>
RecentList<T>::const_iterator::const_iterator(Node* p){
curr_=p;
}
template <typename T>
typename RecentList<T>::const_iterator RecentList<T>::const_iterator::operator++() const{
//++it
curr_ = curr_->next_;
return *this;
}
ただし、コンパイルしようとすると、次のような 42 個のエラーが表示されます。
「RecentList::const_iterator::operator++(int) const」、次から参照:
最後にリンカーエラーがあります。
また、テンプレートが存在する理由は、リスト クラスがテンプレートを使用するためです。その構文を含めないと、Xcode はそれを好まない。
問題を修正するにはどこを見ればよいですか?