Not sure how to explain it – I’m pretty new to C++, but… let me try:
Let’s say I have 300+ names (Jeff, Jack…) with 300+ int values (0 or 1). In JS I would use JSON. Something like this:
var people = {"person": [
{"name": "Jeff","val": 0},
{"name": "Jill","val": 1},
{"name": "Jack","val": 0},
{"name": "Jim","val": 1},
{"name": "John","val": 0}
]}
What’s the best way to do this in C++?
Thanks.
If you can have duplicate names you can’t use a map, so you could use something like this:
If you wanted uniqueness of names you could do something like this:
or
If you’re using this code a lot you can clean up the repeated cruft.
Hope this gives you some ideas.