|
inetinfos 님이 쓰신 글 :
: g++컴파일러는 다음과 같은 경고를 하네요.
: g++가 아직 구식이라 그런가요?
gcc 버전을 확인해보세요. 제가 가진 gcc 2.96/3.1 버전과 C++빌더 6(BC++ 5.6),
Kylix 3(BC++ 5.7)에서는 워닝도 전혀 없이 컴파일 잘 되네요.
: 그리고 템플릿클래스선언은 정의와 같은 파일에 있어야한다는데 왜 그런가요?
템플릿 클래스 정의는 클래스 정의가 아니기 때문입니다.
template이란, 말 그대로 '틀'입니다.
클래스라는 붕어빵을 찍어내는 '붕어빵틀'이지 '붕어빵'자체가 아닙니다.
컴파일을 해야지만 코드가 생성됩니다.
그래서 템플릿 클래스 정의는 항상 헤더 파일로만 존재합니다.
당근 *.obj나 *.lib, *.dll로는 만들 수 없죠.
(그래서 템플릿 라이브러리를 쓴 코드는 컴파일 속도가 오래 걸리는 겁니다.)
: C:\ex\cpp>g++ main.cpp
: In file included from main.cpp:3:
: DoubleLinkedList.h:252: warning: `typename DoubleLinkedList<T>::Entry' is
: implicitly a typename
: DoubleLinkedList.h:252: warning: implicit typename is deprecated, please see
: the documentation for details
:
: 252째줄: 마지막에서 위로 두번째 메서드입니다.
:
:
:
:
: 김백일 님이 쓰신 글 :
: : inetinfos 님이 쓰신 글 :
: : : 다음과같은 오류가 나는데요.
: : : 몇시간을 붙잡고 늘어져도 이유를 모르겠습니다.
: : : 어떻게 잘못되었는지 가르쳐주시면 감사하겠습니다
: : :
: : : C:\ex\cpp>bcc32 main.cpp
: : : Borland C++ 5.6 for Win32 Copyright (c) 1993, 2002 Borland
: : : main.cpp:
: : : Error E2316 DoubleLinkedList.h 56: 'DoubleLinkedList<T>::Entry<T>::Entry()' is n
: : : ot a member of 'DoubleLinkedList<T>::Entry<T>'
: : : Error E2316 DoubleLinkedList.h 60: 'DoubleLinkedList<T>::Entry<T>::Entry(const T
: : : &)' is not a member of 'DoubleLinkedList<T>::Entry<T>'
: : : Error E2316 DoubleLinkedList.h 66: 'DoubleLinkedList<T>::Entry<T>::~Entry()' is
: : : not a member of 'DoubleLinkedList<T>::Entry<T>'
: : : Error E2040 DoubleLinkedList.h 257: Declaration terminated incorrectly
: : : *** 4 errors in Compile ***
|