2011-02-02 14 views
1
//arrayList.h 
template<class T> 
class arrayList{ 
public: 
    // constructor, copy constructor and destructor 
    arrayList(int initialCapacity = 10); 
    arrayList(const arrayList<T>&); 
    ~arrayList(); 
    // iterators to start and end of list 
    class iterator; 
    class seamlessPointer; 
    seamlessPointer begin(); 
    seamlessPointer end() ; 
    protected: 
     T* position; 
    }; // end of iterator class 

protected: 
    T* element; 
    int arrayLength; 
    int listSize; 
}; 


//main.cpp 


int main() { 

...........ネストされたイテレータエラー

sort(dict.begin, dict.end(),compare_nocase); //// 
    return 0; 
} 

2つのエラーは、次のとおりです。

..\src\test.cpp: In function 'int main()': 
..\src\test.cpp:50:44: error: no matching function for call to 'sort(<unresolved overloaded function type>, arrayList<std::basic_string<char> >::seamlessPointer, bool (&)(std::string, std::string))' 

..\src\/arrayList.h: In member function 'arrayList<T>::seamlessPointer arrayList<T>::end() [with T = std::basic_string<char>]': 
..\src\test.cpp:50:28: instantiated from here 
..\src\/arrayList.h:114:3: error: 'arrayList<T>::seamlessPointer::seamlessPointer(T*) [with T = std::basic_string<char>]' is private 
..\src\/arrayList.h:49:44: error: within this context 

は、なぜ私はこれらのエラーを得るのですか?問題が解決される

EDIT。おかげ

答えて

3

は、私は問題の一つは、あなたがコードをコンパイルせず

sort(dict.begin, dict.end(),compare_nocase); 

代わりの

sort(dict.begin(), dict.end(),compare_nocase); 

dict.begin後の括弧に注意してください)

を書いたことを自分自身であることを考えますここに何か他のものが潜んでいるかどうかわからない。私は何かを見つけたら、この答えを見て更新していきます。

編集:私はあなたのseamlessPointerクラスがそれらのいずれかを使用コンパイル時エラーになるだろうそのメンバ関数public、のいずれかをマークしていないことに気づいた。それはおそらく、あなたが得ている他のエラーを少なくとも部分的に担当しているでしょう。

+0

これを修正しました。しかし、より多くの誤りがあります。 – Sean

+0

エラーが関連している最も「のArrayList :: seamlessPointer&ArrayListの :: seamlessPointer ::演算子+(INT)[T = STDと:: 、ArrayListのをのbasic_string :: = seamlessPointerのArrayList > :: seamlessPointer] 'はプライベートです – Sean

+0

@ Sean-別の修正で更新されました。これを確認できますか? – templatetypedef

2

2番目のエラーは、seamlessPointerクラスのpublic:アクセス指定を省略したようです。 C++のクラスメンバーはデフォルトでプライベートであるため、コードの残りの部分でコンストラクタやメンバ関数にアクセスすることはできません。