I’d like to create a map with an int and my own custom class. Is there a way to do this?
map<int, MyClass> myMap;
If not, how do I go about accomplishing this? Basically, I want an id(or preferably an enum) to point to my own custom class. In most other languages, this would be a simple hash.
You do need
MyClassto be default- and copy- constructible, so it can be created (if you use, e.g.,myMap[5]) and copied into the map.