Reputation: 139
I am trying to creating a two D array of linked lists (without using std). I would like to use my class based implementation of LinkedList. I want a main list of Foo nodes each Foo node to have a list of Bar nodes. However, I can't figure out how to define that in the Foo node struct
struct Foo {
Foo *next;
int fooVal;
LinkedList *list; /// doesn't work
}
struct Bar {
Bar *next;
string barVal;
}
class LinkedList {
private:
foo *head;
public:
.....
}
Upvotes: 0
Views: 70
Reputation: 82006
struct Bar {
Bar *next;
string barVal;
}
struct Foo {
Foo *next;
int fooVal;
Bar *head_of_bars;
};
class LinkedList {
private:
Foo *head_of_foos;
};
Upvotes: 1