C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[19412] Re:템플릿 클래스는 단지 클래스(타입)을 만들어 내기 위한 틀(템플릿)에 불과합니다.
김백일 [cedar] 801 읽음    2002-06-17 10:36
즉, 템플릿 클래스의 이름 자체는 타입이 아닙니다!
그래서 < >안에 타입이름을 같이 써야 타입이 됩니다.

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)라고 합니다.)

숙제 등으로 제출하실 경우를 제외하면,
따로 이러한 리스트 클래스를 굳이 만드실 필요가 없습니다.

+ -

관련 글 리스트
19402 템플릿을 사용한 클래스의 참조를 파라미터 값으로 받는 함수... exkarion 772 2002/06/16
19412     Re:템플릿 클래스는 단지 클래스(타입)을 만들어 내기 위한 틀(템플릿)에 불과합니다. 김백일 801 2002/06/17
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.