home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD2.mdf
/
c
/
tcpp
/
examples
/
stack2.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1990-06-09
|
499b
|
34 lines
// stack2.cpp: Implementierung der Klasse Stack
// Aus Kapitel 6 der Einführung
#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";
}