home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
Dloads
/
OTHERUTI
/
TCPP30-3.ZIP
/
EXAMPLES.ZIP
/
EX9.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-02-18
|
691b
|
32 lines
// Borland C++ - (C) Copyright 1991 by Borland International
// ex9.cpp: Using the print() virtual function
// from Hands-on C++
#include <iostream.h>
#include "stack2.h"
main()
{
Stack s(5);
List l, *lp;
int i = 0;
// Insert the numbers 1 through 5 into the stack
while (s.push(i+1) == 0)
++i;
// Put a couple of numbers into the list
l.put_elem(1,0);
l.put_elem(2,1);
l.setn(2);
cout << "Stack:\n";
lp = &s; // line 22
lp->print(); // Invoke the Stack print() method; line 23
cout << "\nList:\n";
lp = &l;
lp->print(); // Invoke the List print() method; line 27
return 0;
}