Tools.h++ Manual

23-6 104011 Tandem Computers Incorporated
23
Example
Program output:
11
5
7
1
Public constructors
RWGDlist(
type
)();
Construct an empty collection.
RWGDlist(
type
)(type* a);
Construct a collection with one entry
a
.
RWGDlist(
type
)(const RWGDlist(
type
)& a);
Copy constructor. A shallow copy of
a
is made.
Assignment operator
void operator=(const RWGDlist
(
type
)& a);
Assignment operator. A shallow copy of
a
is made.
#include <rw/gdlist.h>
#include <rw/rstream.h>
declare(RWGDlist,int) /* Declare a list of ints */
main()
{
RWGDlist(int) list; // Define a list of ints
list.insert(new int(5)); // Insert some ints
list.insert(new int(7));
list.insert(new int(1));
list.prepend(new int(11));
RWGDlistIterator(int) next(list);
while( int* ip = next() )
cout << *ip << endl; // Print out the members
}