#dictionaries in C++

9 messages · Page 1 of 1 (latest)

opaque agate
#

So I have a custom class which is a button, i put them in a std::vector, however this isn't ideal as when I am reading specific buttons it looks like buttons[0] instead of buttons["pause"]

uncut arrowBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

lunar kraken
#

map/unordered_map

pliant lake
#

Dictionaries in C++ is called as Map.
Use std::map or std::unordered_map

heady bloom
#

I would argue though, using the ordered version is often somewhat rare

#

as often you do not care about the order

rough anvil
#

here's a simple idea: instead of putting your buttons into a container just so that you can then access them via a string literal as name, why not just do

Button pause;
```i.e., just give the thing an actual name?
opaque agate
uncut arrowBOT
#

This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.