[Solved] [] operator in std::map is giving me segmentation fault [closed]

Maybe your myMap is no longer accessible. For instance, it might be a reference to a deleted pointer, or, much more probable, a member variable of an already deleted class: class MyClass { public: selfInsert(std::string myKey) { if(!myKey.empty()) { myMap[myKey] = this; } } private: std::map<std::string, myClass*> myMap; } int main() { MyClass *a = … Read more