vendredi 3 juillet 2015

How to imitate Python like dictionaries in C++ using STL?

I have a data structure which looks like this. It's more like a dictionary in python and it stores information like this.

D={0:{'x':2,'y':5},1:{'x':4,'y':5}}

This represents two keys 0 and 1, each having x and y coordinates. In Python I can easily initialize like this.

But how can I do it in C++? I have used the following declaration.

map<int, map<char, float>> D;

But after this I am unable to proceed. Any help?

Aucun commentaire:

Enregistrer un commentaire