Re[2]: derived templates doesn't link in Visual C++ 6.0
От:
Аноним
Дата:
10.11.01 22:05
Оценка:
Здравствуйте Андрей, Вы писали:
А>Здравствуйте Martyn2000, Вы писали:
M>>Привет!
[...skipped...]
А>Перенеси реализацию ActorThread (то, что я выделил) в файл a.h и все проблемы исчезнут.
Не совсем. Я забыл написать, что деструкторы у Actor & ActorThread должны быть виртуальными (иначе смысла нет) :-))). Т.е. конструктор-то я могу перенести в хедер, но толку-то... Впрочем, и это не помогает, тогда компилер начинает ругаться:
=== a.h
[vc]
class Event : public CObject {
DECLARE_DYNAMIC( Event );
public:
Event();
virtual ~Event();
};
class Actor {
public:
Actor();
virtual ~Actor();
};
template <class T, class C>
class ActorThread : public Actor {
public:
ActorThread()
{ m_thread = AfxBeginThread( RUNTIME_CLASS( T ) ); }
virtual ~ActorThread();
private:
CWinThread* m_thread;
};
[/vc]
a.h(19) : error C2039: 'classT' : is not a member of 'CWinThread'
c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(3791) : see declaration of 'CWinThread'
a.h(19) : while compiling class-template member function '__thiscall ActorThread<class CWinThread,class CObject>::ActorThread<class CWinThread,class CObject>(void)'
a.h(19) : error C2065: 'classT' : undeclared identifier
a.h(19) : while compiling class-template member function '__thiscall ActorThread<class CWinThread,class CObject>::ActorThread<class CWinThread,class CObject>(void)'
Похоже, что надо искать другое решение, без темплейтов.....