2011-02-02 6 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; 
} 

두 오류는 다음과 같습니다

..\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 = 표준 : 를 basic_string, ArrayList를 seamlessPointer :: = ArrayList를 <표준 : 를 basic_string> :: seamlessPointer] '이 (가) – Sean

+0

@ Sean- 다른 수정 프로그램으로 업데이트되었습니다. 이것을 확인할 수 있습니까? – templatetypedef

2

두 번째 오류의 경우 seamlessPointer 클래스에서 public: 액세스 지정자를 생략 한 것 같습니다. C++의 클래스 멤버는 기본적으로 비공개이므로 나머지 코드에서는 해당 생성자 또는 멤버 함수에 액세스 할 수 없습니다.