Storing Data in a Tree-Like Structure?

In my code, I need to find a way to store multiple data types together in a sort of tree structure, like this, https://s1.postimg.org/mb6r8nuz3/tree_ex.png , where the red boxes are type COURSE (a struct), the green boxes are type STUDENT (a different struct), and the red boxes are type int.

Currently, I have separate dynamic arrays for each of them, like so:
1
2
3
COURSE *arrc = new COURSE[1];
STUDENT *arrs = new STUDENT[1];
int *arrg = new int[1];


I am able to store and retrieve data from these just fine, but I want to know how to connect them. Any idea how I would go about doing this?
Last edited on
Put this information together into another struct?
1
2
3
4
5
6
7
8
struct COURSE{};
struct STUDENT{};
struct Enrollement
{
    COURSE m_c;
    STUDENT m_s;
    int m_i;
};

http://www.learncpp.com/cpp-tutorial/102-composition/
Topic archived. No new replies allowed.