I'm trying to mimic the python dictionary in C++. For example I want to build something like
{"The Dark Night Rises": {"year": 2012, "StoryLine": "this is the story.....", "Genres": ["action","crime","Thriller"]}}
I'm using the STL map and lists for building up this kind of dictionary. But I'm not sure how to use the iterators. Can some one help me with an example of building the above dictionary. I started something like below to just build a simple dictionary like {"cast":["action","crime","Thriller"]}
. I'm confused how to build the above mentioned multilevel dictionaries, and specially iterating over them.
#include<iostream>
#include<string>
#include<map>
#include<iterator>
#include<list>
using namespace std;
class MultiLevDict
{
private:
list<string> lis;
map<string,list<string> > MultiDict;
public:
void Setter();
void Display() const;
};
void MultiLevDict::Setter()
{
string field;
string cast;
int sizeCast;
cout<<"enter the field of the movie:";
cin>>field;
cout<<endl;
cout<<"how many cast are there in this movie?:";
cin>>sizeCast;
for (int i=0; i<sizeCast; i++)
{
cin>>cast;
lis.push_back(cast);
}
MultiDict[field]=lis;
}
void MultiLevDict::Display() const
{
list<string>::iterator lisIt;
}