i have following 2 structs which are defined within a template class and a container, which holds elements of the base class, as follows:
class template<typename T1, typename T2>
class TTestDataObject
{
private:
//base element
struct SDataContainerElement
{
T1* m_sData;
};
//derived element
struct SInvalidDataContainerElement : SDataContainerElement
{
int m_eExpectedErrorCode;
};
//container holding base elements
typedef std::map<T2, SDataContainerElement* > TDataContainer;
TDataContainer sCInvalidData;
public:
typedef TDataContainer::const_iterator TDataConstIterator;
}
I want to implement a method, which can extract information from this container, doing different things depending on which element it has, the base class (SDataContainerElement) or the derived class (SInvalidDataContainerElement) and I implemented it as follows :
template<typename TDataStruct, typename TDataEnum>
int TTestDataObject<T1, T2>::eGetExpectedError(T2 eIndex)
{
TDataConstIterator sElement = sCInvalidData.find(eIndex);
if(dynamic_cast<SInvalidDataContainerElement*>((sElement->second)) == NULL)
return -1;
else
return static_cast<int>(sElement->second->m_eExpectedError);
}
Trying to compile leads to the following error :
E2307 Type'TTestDataObject<BEREICHTYP,eTestDataBereichTyp>::SDataContainerElement' is not a defined class with virtual functions
I don't understand this. Can anybody explain this error to me and show me a solution pls?
Thanks in advance!