0

In java this code works pretty good:

static void f(){
    HashMap hm = new HashMap<>();
    hm.put("string", 1234);
    hm.put(2134, "string");
    System.out.println(hm.get(2134));
    System.out.println(hm.get("string"));
}

can i make this feature in c++? (maybe decltype hash and 3-dimensional container??)

Cus
  • 111
  • 4
  • 4
    Does this answer your question? [Creating a Variant class and std::map](https://stackoverflow.com/questions/58868341/creating-a-variant-class-and-stdmapvariant-variant) – Botje Apr 15 '20 at 09:10
  • In Java everything inherits from Object, which has equals() and hashCode() methods. You'll need to implement those somehow for a hash map, or the `<` operator in order to use a binary tree. – rustyx Apr 15 '20 at 09:20

0 Answers0