Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道这段代码是否真的会存储一个指向由地图管理的对象的指针:
std::map<std::string,MapType> map; MapType* typePointer; typePointer = map[someKey];
typePointer = &map[someKey];
不,不会的。
您正在存储MapType,而不是MapType*在地图内。因此,最后一行是类型不匹配并且不会编译。
MapType
MapType*