Joel Uckelman on 6 Jun 2002 18:58:21 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[hosers-talk] classes with pointers to each other


How do I make this work?

class Foo {
   public:
      List<Bar> *list;
}

class Bar {
   public:
      List<Foo> *list;
}

The lists are for keeping track of which Foo are associated with which Bar 
and vice versa, since it would be much slower if, each time I need to know 
which Foo are associated with a particular Bar, I have to check every Foo. 
Can classes be interdefined like this?

-- 
J.