Usage problem on std::unordered_map
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13

Thread: Usage problem on std::unordered_map

Threaded View

  1. #1
    Join Date
    Dec 2010
    Posts
    648

    Usage problem on std::unordered_map

    There is an error saying that unordered_map has no associated operator '->'
    Any ideas why?
    Thanks
    Jack

    Code:
    #ifndef _OGREDETOURCROWDBASE_H_
    #define _OGREDETOURCROWDBASE_H_
    
    class OgreDetourCrowdBase {
    public:
        virtual Ogre::Real getAgentHeight(void) = 0;  
        virtual Ogre::Real getAgentRadius(void) = 0;
        virtual int getNbAgents(void) { return 0; }
        virtual int getMaxNbAgents(void) { return 0; }
    };
    
    
    #endif
    
    std::unordered_map<std::string, OgreDetourCrowdBase*> mDetourCrowd;
    
    OgreDetourCrowdBase *detourCrowd = new OgreDetourCrowd(mRecast);
    OgreDetourCrowdBase *detourCrowdCB = new OgreDetourCrowdCB(mRecastCB);
    OgreDetourCrowdBase *detourCrowdVNA = new OgreDetourCrowdVNA(mRecastVNA);
    OgreDetourCrowdBase *detourCrowdLorry = new OgreDetourCrowdLorry(mRecastLorry);
    
    mDetourCrowd["Worker"] = detourCrowd;
    mDetourCrowd["CB"] = detourCrowdCB;
    mDetourCrowd["VNA"] = detourCrowdVNA;
    mDetourCrowd["Lorry"] = detourCrowdLorry;
    
    ObjectBase *OgreRecastApplication::createOperators(Ogre::String name, Ogre::Vector3 position) {
    	if(mDetourCrowd["Worker"]->getNbAgents() >= mDetourCrowd["Worker"]->getMaxNbAgents()) {
            Ogre::LogManager::getSingletonPtr()->logMessage("Error: Cannot create crowd agent for new Worker. Limit of "+Ogre::StringConverter::toString(mDetourCrowd->getMaxNbAgents())+" reached", Ogre::LML_CRITICAL);
            throw new Ogre::Exception(1, "Cannot create crowd agent for new Worker. Limit of "+Ogre::StringConverter::toString(mDetourCrowd->getMaxNbAgents())+" reached", "OgreRecastApplication::getOrCreateCharacter("+name+")");
        }
    
         
        ObjectBase *worker = new Worker(name, mSceneMgr, mDetourCrowd, mDebugDraw, position);
        mObjects.push_back(worker);
        return worker;
    
    }
    Error 1 error C2819: type 'std::tr1::unordered_map<_Kty,_Ty>' does not have an overloaded member 'operator ->' e:\jacky\documents\visual studio 2010\projects\ogrecrowd\ogrecrowd\samples\src\ogrerecastapplication.cpp 379 1 OgreRecast
    Error 2 error C2039: 'getMaxNbAgents' : is not a member of 'std::tr1::unordered_map<_Kty,_Ty>' e:\jacky\documents\visual studio 2010\projects\ogrecrowd\ogrecrowd\samples\src\ogrerecastapplication.cpp 379 1 OgreRecast
    Error 3 error C2819: type 'std::tr1::unordered_map<_Kty,_Ty>' does not have an overloaded member 'operator ->' e:\jacky\documents\visual studio 2010\projects\ogrecrowd\ogrecrowd\samples\src\ogrerecastapplication.cpp 380 1 OgreRecast
    Error 4 error C2039: 'getMaxNbAgents' : is not a member of 'std::tr1::unordered_map<_Kty,_Ty>' e:\jacky\documents\visual studio 2010\projects\ogrecrowd\ogrecrowd\samples\src\ogrerecastapplication.cpp 380 1 OgreRecast
    Error 5 error C2664: 'Worker::Worker(Ogre::String,Ogre::SceneManager *,OgreDetourCrowd *,bool,Ogre::Vector3)' : cannot convert parameter 3 from 'std::tr1::unordered_map<_Kty,_Ty>' to 'OgreDetourCrowd *' e:\jacky\documents\visual studio 2010\projects\ogrecrowd\ogrecrowd\samples\src\ogrerecastapplication.cpp 384 1 OgreRecast
    ....
    [/code]
    Last edited by lucky6969b; June 12th, 2014 at 04:56 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center