I am just trying to declare a map iterator but I get a compile error saying "expected ; before it"
I believe it is because I haven't included the whole std namespace (using namespace std;) but I intentionally dont want to include all of it.
My code:
#include <map>
#include <string>
template <class Object>
class Cont
{
public:
Cont() {}
Object* get( unsigned int nID )
{
std::map <unsigned int, Object*>::iterator it = m.begin(); // error here "expected ; before it" what is this error?
for ( ; it != m.end(); it++ )
{
if ( (*it).second->ID == nID ) { return (*it).second; }
}
return NULL;
}
std::map <unsigned int, Object*> m;
};
I have tried this aswell but it doesn't work:
std::map <unsigned int, Object*>::std::iterator it = m.begin();