27 lines
515 B
C
27 lines
515 B
C
|
#ifndef __STACK_H
|
||
|
#define __STACK_H
|
||
|
|
||
|
#ifndef __ARRAY_H
|
||
|
#include <array.h>
|
||
|
#endif
|
||
|
|
||
|
// @C
|
||
|
// Classe TStack : private TArray
|
||
|
// @END
|
||
|
|
||
|
class TStack : private TArray
|
||
|
{
|
||
|
// @DPRIV
|
||
|
int _sp; // Puntatore alla cima dello stack
|
||
|
|
||
|
public:
|
||
|
// @FPUB
|
||
|
TStack(int size); // Chiama il costruttore di TArray(size)
|
||
|
|
||
|
int count() const { return _sp; } // Ritorna il puntatore allo stack
|
||
|
void push(const TObject&); // Aggiunge un oggetto sullo stack
|
||
|
TObject& pop(); // Ritorna il primo oggetto sulla cima dello stack
|
||
|
};
|
||
|
|
||
|
#endif
|