Nathan Takemori
Nathan Takemori

Reputation: 139

Implementation of 2D LinkedList

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

Answers (1)

Bill Lynch
Bill Lynch

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

Related Questions