這裏沒有匹配的成員函數是導致該錯誤代碼:呼叫爲 '刪除'
Factory.h:
#include <string>
#include <map>
namespace BaseSubsystems
{
template <class T>
class CFactory
{
protected:
typedef T (*FunctionPointer)();
typedef std::pair<std::string,FunctionPointer> TStringFunctionPointerPair;
typedef std::map<std::string,FunctionPointer> TFunctionPointerMap;
TFunctionPointerMap _table;
public:
CFactory() {}
virtual ~CFactory();
}; // class CFactory
template <class T>
inline CFactory<T>::~CFactory()
{
TFunctionPointerMap::const_iterator it = _table.begin();
TFunctionPointerMap::const_iterator it2;
while(it != _table.end())
{
it2 = it;
it++;
_table.erase(it2);
}
} // ~CFactory
}
和錯誤,我得到:
error: no matching member function for call to 'erase' [3]
_table.erase(it2);
~~~~~~~^~~~~
任何提示? 謝謝。
什麼是'it2'的需要? '_table.erase(it ++)'怎麼樣? – iammilind 2012-02-06 03:21:17