|
안녕하세요.
TList를 좀 편하게 써보려고 아래와 같이 템플릿 클래스로 만들어봤습니다.
===================================================
template <class T>
class TTList : public TList
{
private:
protected:
T * __fastcall GetItems( int Index );
void __fastcall SetItems( int Index, T * Item );
public:
__fastcall TTList( );
virtual __fastcall ~TTList( );
void __fastcall Add( T * Item );
void __fastcall Clear( );
__property T * Items[ int Index ] =
{
read = GetItems,
write = SetItems
} ;
} ;
template <class T>
__fastcall TTList<T>::TTList( )
: TList( )
{
}
template <class T>
__fastcall TTList<T>::~TTList( )
{
OutputDebugString(L"TTList<T>::~TTList");
Clear( );
}
template <class T>
T * __fastcall TTList<T>::GetItems( int Index )
{
return ( T * )TList::Get( Index );
}
template <class T>
void __fastcall TTList<T>::SetItems( int Index, T * Item )
{
TList::Put( Index, Item );
}
template <class T>
void __fastcall TTList<T>::Add( T * Item )
{
TList::Add( Item );
}
template <class T>
void __fastcall TTList<T>::Clear( )
{
for ( int i = 0; i < this->Count; i++ )
{
T * Item = ( T * )this->Items[ i ];
delete Item;
}
TList::Clear( );
}
==================================================
그런데 저 리스트에서 특정 기능이 필요해서
TTList를 상속받는 클래스를 정의 했는데 소멸자 쪽에서 자꾸 에러가 납니다.
template <class T>
class TOrderingList : public TTList<T>
{
private:
public:
__fastcall TOrderingList();
__fastcall ~TOrderingList();
};
template <class T>
__fastcall TOrderingList<T>::TOrderingList( )
: TTList<T>( )
{
}
왜 이것만 하면 오류가 날까?
template <class T>
__fastcall TOrderingList<T>::~TOrderingList( )
{
}
TOrderingList 사용 부분
1. 선언
TOrderingList<ORD_ITEM>* m_lstOrdItem;
2. 인스턴스 생성
m_lstOrdItem = new TOrderingList<ORD_ITEM>();
TOrderingList를 TTList로 변경하면 문제 없이 컴파일 되고,
TOrderingList의 소멸자 함수 선언부와 구현부를 모두 주석처리 하면 문제 없이 컴파일 됩니다.
대체 제가 뭘 잘못 한걸까요?
|