|
즉, 템플릿 클래스의 이름 자체는 타입이 아닙니다!
그래서 < >안에 타입이름을 같이 써야 타입이 됩니다.
exkarion 님이 쓰신 글 :
: 제목이 무쟈게 길군요....ㅡ.ㅡ;;;
:
: 죄송하구요....여튼 제목대로 템플릿을 사용한 클래스의 인스턴스의
:
: 참조를 파라미터 값으로 받는 함수를(헥헥헥) 만든다고 만들었는데요...
:
: 에러가 뜨는군요....ㅡ.ㅡ;;;;;
:
: 밑에 소스의 부분을 써놓을테니 많은 조언 부탁드립니다.
:
: 답변해주실분에게 미리 감사드립니다. ^^
:
: #ifndef LIST_H
: #define LIST_H
:
: #include <iostream>
: using namespace std;
:
: template <typename Elmt_Type>
: class ListElmt
: {
: private: //템플릿을 이용하여 데이터를 생성
: Elmt_Type data;
: ListElmt* next;
ListElmt<Elmt_Type> *next;
: int number;
:
: public:
: ListElmt();
: ListElmt(const ListElmt &element);
ListElmt(const ListElmt<Elmt_Type>& element);
: ~ListElmt();
: friend int list_is_head(const List &list, const ListElmt &element);
: int list_is_tail(const ListElmt &elemnt);
: Elmt_Type list_data(const ListElmt &element);
: ListElmt* list_next(const ListElmt &element);
friend int list_is_head(const List<Elmt_Type> &list, const ListElmt<Elmt_Type> &element);
int list_is_tail(const ListElmt<Elmt_Type> &elemnt);
Elmt_Type list_data(const ListElmt<Elmt_Type> &element);
ListElmt* list_next(const ListElmt<Elmt_Type> &element);
: };
:
: template <typename List_Type>
: class List
: {
: private:
: int size;
: ListElmt* head; <=에러
: ListElmt* tail; <=에러
: public:
: List();
: List(const List &list);
List(const List<List_Type> &list);
: ~List();
: int list_ins_next(List &list, ListElmt &element);
: int list_ins_next(List &list, List_Type data, int number);
: int list_del_next(List &list, ListElmt &element);
: int list_del_next(List &list, int number);
: int list_size(List &list);
: ListElmt* list_head(List &list);
: ListElmt* list_tail(List &list);
: friend int list_is_head(const List &list, const ListElmt &element); <=에러
: void list_view(List &list);
int list_ins_next(List<List_Type> &list, ListElmt<List_Type> &element);
int list_ins_next(List<List_Type> &list, List_Type<List_Type> data, int number);
int list_del_next(List<List_Type> &list, ListElmt<List_Type> &element);
int list_del_next(List<List_Type> &list, int number);
int list_size(List<List_Type> &list);
ListElmt* list_head(List<List_Type> &list);
ListElmt* list_tail(List<List_Type> &list);
friend int list_is_head(const List<List_Type> &list, const ListElmt<List_Type> &element); <=에러
void list_view(List<List_Type> &list);
: };
:
: #endif
참고로, ANSI C++ 라이브러리(namespace std)에는
list, vector, deque, set, map 과 같은
자주 사용되는 자료구조가 이미 들어있습니다.
(이러한 라이브러리를 ANSI C++에서는 STL(Standard Template Library)라고 합니다.)
숙제 등으로 제출하실 경우를 제외하면,
따로 이러한 리스트 클래스를 굳이 만드실 필요가 없습니다.
|