Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!gatech!ncar!tank!uxc!uxc.cso.uiuc.edu!a.cs.uiuc.edu!m.cs.uiuc.edu!shirley From: shirley@m.cs.uiuc.edu Newsgroups: comp.lang.c++ Subject: Reuseable data structures? Message-ID: <4800034@m.cs.uiuc.edu> Date: 1 Sep 88 03:07:00 GMT Lines: 38 Nf-ID: #N:m.cs.uiuc.edu:4800034:000:1116 Nf-From: m.cs.uiuc.edu!shirley Aug 31 22:07:00 1988 I have a simple question that may or may not have a simple answer. If I want to write code for a certain data structure, say a linked list, and I want to use it for all classes, can C++ handle this gracefully? For example, suppose I define a base class "thing", and classes "list" and "list_node" (probably subclasses of "thing") that define the linked list ADT for things. Each list node contains a pointer to thing. Now I define a subclass of thing "integer" that has an access function "void set_value()". I want code that is the equiv. of list int_list; integer i, j; i.set_value(7); int_list.add(i); j = int_list.first(); j.print(); I want to be able to do this using the 'thing-list', and I want to use it on all sorts of very different subclasses of thing. How about it? Sorry if this is too simple a question. I am new to C++ and my only other language is vax-assembler. THANKS! Peter Shirley University of Illinois at Urbana-Champaign UUCP: {pur-ee,convex,inhp4}!uiucdcs!shirley ARPA: shirley@cs.uiuc.edu CSNET: shirley%uiuc@csnet-relay