I declare hash_map<string, Factor*> hashFactor;
Factor is a base class, and I want to store the pointer of its derived classes.
DoubleFactor dbFactor(fname);
dbFactor.setValueFrom(svalue);
dbFactor.setParam(sparam);
dbFactor.setMethod(smethod);
listFactor.push_back(dbFactor);
Factor* baseFactor = &dbFactor;
hashFactor.insert(fname, &baseFactor);
But I got compiler error.
1 IntelliSense: no instance of overloaded function "stdext::hash_map<_Kty, _Ty, _Tr, _Alloc>::insert [with _Kty=std::string, _Ty=Factor *, _Tr=stdext::hash_compare<std::string, std::less<std::string>>, _Alloc=std::allocator<std::pair<const std::string, Factor *>>]" matches the argument list
argument types are: (std::string, Factor **)
object type is: stdext::hash_map<std::string, Factor *, stdext::hash_compare<std::string, std::less<std::string>>, std::allocator<std::pair<const std::string, Factor *>>>
DoubleFactor is a derived class of Factor. What should I code? I haven't used hash_map. please ignore the grammar of my language. Thank you.