0
Help with C++ maps and OOP
Hello guys, How do you insert an object to a map? Basically, I have a list of bank accounts that I want to put them into a map. Account is a class with a constructor that has 3 parameters (name, number, type). So my aim is to put an account object to the map having a key the number and value the object account. Do you know how to do it?
1 Réponse
+ 1
There are multiple different ways how you can insert an object into a map, therefore I would suggest you to visit the documentation to get more familiar with it:
https://en.cppreference.com/w/cpp/container/map
Three main ways would include the overloaded [] operator, the insert method, and the emplace method, as can be seen here:
https://code.sololearn.com/cnzOL5KwECr4/?ref=app