home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_07
/
1107120b
< prev
next >
Wrap
Text File
|
1993-05-06
|
474b
|
36 lines
//
// list.cpp - list implementation
//
#include <stdio.h>
#include "list.h"
list::list(unsigned n)
{
first = last = new node (n, 0);
}
list::~list()
{
node *p;
while ((p = first) != 0)
{
first = first->next;
delete p;
}
}
void list::add(unsigned n)
{
if (last->number != n)
last = last->next = new node (n, 0);
}
void list::print()
{
for (node *p = first; p != 0; p = p->next)
printf("%4u ", p->number);
}