samedi 1 août 2015

C++ Accessing Class Pointer Stored In Map

Here's my code:

class BCConVar
{
public:
    BCConVar ( ) { }
};

template<class T>
class CConVar : public BCConVar
{
    T& m_cvar;
public:
    T& Cvar ( ) const { return m_cvar; }
    void Cvar ( T& val ) { m_cvar = val; }
    CConVar ( T& );

};

class CCvars
{
public:
    std::map<std::string, BCConVar*> cVars;
};

I initialize it like:

 cVars.insert ( std::make_pair ( std::string ( "test1" ), new CConVar<float> ( pCvars->settings.test ) ) );

How can I access pointer stored in map? Visual Studio is showing me hints that I should write cVars[cvar ].BCConVar but that's wrong, how can I access pointer stored under key X ?

Aucun commentaire:

Enregistrer un commentaire