I had created a class inheriting std::map
and trying to get value at particular index using an method.
#define MYAPI_EXPORTS
#ifdef MYAPI_EXPORTS
#define MY_API __declspec(dllexport)
#else
#define MY_API __declspec(dllimport)
#endif
template<class _Value>
class MY_API MyDictionary : public std::map<std::string, _Value>
{
_Value GetItem(int index)
{
std::map<std::string, _Value>::iterator itr = this->begin(); //compile error at this line
int c = 0;
while (c < index)
{
itr++;
c++;
}
return itr->second;
}
};
'std::map::iterator itr' this line shows error while compiling.
the errors are
error C2760: syntax error: unexpected token 'identifier', expected ';'
error C7510: 'iterator': use of dependent type name must be prefixed with 'typename'
It seems like iterator type is not defined in compile time. Is there any solution to fix this?