Ошибка компиляции шаблона без включения заголовка "string", даже если я добавлю заголовок "iostream"!
//----------------------------------------------------------
// Header : Factory.h
//----------------------------------------------------------
template <typename TKey, typename TObject>
class Factory
{
public :
std::map<TKey, TObject*> m_mapReference;
void Register(TKey key,TObject *obj){
if(m_mapReference.find(key)==m_mapReference.end())
m_mapReference[key]=obj;
}
};
class A
{ };
class B : public A
{ };
//----------------------------------------------------------
// Main.cpp
//----------------------------------------------------------
#include <iostream>
//#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string strType = "B";
B b;
Factory< string, A > fact;
fact.Register(strType, &b);
}
vc \ include \ xfunctional (125): ошибка C2784: 'bool std :: operator <(const std :: _ Hash <_Traits> &, const std :: _ Hash <_Traits> &)': невозможно определить тип аргумента для const std :: _ Hash <_Traits> & 'partir de' const std :: string '