2013-05-05 4 views
1

헤더 파일에 구조체가 선언되었습니다. 아래에서 볼 수 있습니다.구조체가 .cpp에 보이지 않습니다.

private: 
    struct Node{ 
     Customer data; 
     Node *next; 
     Node *prev; 
    }; 
Node* find (const int index) const; 

그리고 Node*을 비공개로 반환한다고 선언되었습니다.

그러나 내 cpp 파일에서 find 함수를 구현하려고하면 "식별자 노드가 정의되지 않음"이라는 오류 메시지가 나타납니다.

Node* CustomerList::find(const int index){ 
    //some random code 
} 

은 cpp를 볼 수 있도록 안 Node되는 문제는 무엇입니까?

+1

과 자격을해야합니까? 'TheClassName :: Node * ...'가 필요합니다. – juanchopanza

답변

4

CustomerListNode을 포함하는 클래스라고 가정합니다. CustomerList 방법 내에서

CustomerList::Node* CustomerList::find(const int index){ 
    //some random code 
} 

그냥 Node을 말할 수 있지만 반환 형식이 다른, 당신은 여전히 ​​Node`이 선언 '은 무엇 클래스 CustomerList::

+0

네, 이제 작동하도록하십시오. 감사! –