Всем доброго времени суток. Возник вопрос по выполнению задания. Вот само задание:
Необходимо разработать класс контейнера, реализующий приведенный ниже интерфейс. При разработке допускается использовать STL.
class ElemNotFound {};
template < class ElemType, class IndexType > class IContainer
{
public:
virtual const ElemType& GetElem( const IndexType& index ) const throw ( ElemNotFound ) = 0;
virtual void PutElem( const IndexType& index, const ElemType& elem ) throw () = 0;
};
Решение надо представить под Windows и Linux.
Выполнил задание, однако отказали, не подскажете в чем косяк ?
template < class ElemType, class IndexType >
class CContainer: public IContainer<ElemType, IndexType>, public map <IndexType, ElemType>
{
public:
inline const ElemType& GetElem( const IndexType& index ) const throw ( ElemNotFound ) {
map<IndexType, ElemType>::const_iterator toRet = find(index);
if (toRet == end()) {
throw ElemNotFound();
}
return toRet->second;
}
inline void PutElem( const IndexType& index, const ElemType& elem ) throw () {
insert(make_pair(index,elem));
}
};