Search code examples
c++dictionarykey

How to get the dictionary key?


I have a structure :

struct node {
    map<string, string> data;
    node* left;
    node* right;
};

And I know there can be only one key-value pair in the data (I know I can use a pair, but the task is to do it with a map - realy strange task) ) So, how can I get the key in some node? For example :

node t;
t.data...

Solution

  • t.data.begin()->first will do the work. But probably you should write the whole task 'cause it's really strange.