Q:

Storing data within a map of a vector of structs of a vector of structs

First post here, and I'm working on some code to try to read from multiples CSV files, combine them into a "Master" CSV file. (CODING in: C++ Visual Studio 2013 by the way)
Anyways, that's not the trouble I'm having. I'm having difficulty with setting up my initial container I would like to store these values into. Here's my set-up so far:
#include <vector>
#include <map>
using namespace std;
    struct GradeCategories{
        string category;
        int grade;
    }; GradeCategories grade_cat;

    struct NameGrades{
        string name;
        vector<GradeCategories> v;
    }; NameGrades NG;

    typedef map<int, vector<NameGrades>> TheBook;

So how would I go about even accessing/inputting data into this set up?
I attempted:
TheBook[12345017][NG.name = "Bob Jones"].push_back((grade_cat.category = "Exam 1")(grade_cat.grade = 95));
Other than that, I don't really see how I would access the internal components of this. Extremely new to maps, and this deep of an "inception" of code is kind of throwing me.
So any help with that would be very appreciated! Thanks :)

A:

Well, TheBook, maps int onto a vector of NameGrades, which means:
TheBook[int] = vector<NameGrades>;

Start with one GradeCatagories object: grade_cat
grade_cat.category = "Exam";
grade_cat.grade = 95;

Now place it in a vector:
vector<GradeCategories> vgc;
vgc.push_back(grade_cat);

Now we can move on to NG:
NG.name = "Bob Jones";
NG.v = vgc;

Now we can insert it into a vector:
vector<nameGrades> vng;
vng.push_back(NG);

Finally, we can insert it into the map:
TheBook tb;
tb[12345017] = vng;

