-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinkedStack.h
More file actions
35 lines (28 loc) · 917 Bytes
/
LinkedStack.h
File metadata and controls
35 lines (28 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//Â Created by Frank M. Carrano and Timothy M. Henry.
//Â Copyright (c) 2017 Pearson Education, Hoboken, New Jersey.
/** ADT stack: Link-based implementation.
Listing 7-3.
@file LinkedStack.h */
#ifndef LINKED_STACK_
#define LINKED_STACK_
#include "StackInterface.h"
#include "Node.h"
template<class ItemType>
class LinkedStack : public StackInterface<ItemType>
{
private:
Node<ItemType>* topPtr; // Pointer to first node in the chain;
// this node contains the stack's top
public:
// Constructors and destructor:
LinkedStack(); // Default constructor
LinkedStack(const LinkedStack<ItemType>& aStack);// Copy constructor
virtual ~LinkedStack(); // Destructor
// Stack operations:
bool isEmpty() const;
bool push(const ItemType& newItem);
bool pop();
ItemType peek() const;
}; // end LinkedStack
#include "LinkedStack.cpp"
#endif