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
/
STACK2.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-02-18
|
557b
|
36 lines
// Borland C++ - (C) Copyright 1991 by Borland International
// stack2.cpp: Implementation of the Stack class
// from Hands-on C++
#include <iostream.h>
#include "stack2.h"
int Stack::push(int elem)
{
if (top < nmax)
{
list[top++] = elem;
return 0;
}
else
return -1;
}
int Stack::pop(int& elem)
{
if (top > 0)
{
elem = list[--top];
return 0;
}
else
return -1;
}
void Stack::print()
{
for (int i = top-1; i >= 0; --i)
cout << list[i] << "\n";
}