- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLinkedStack.h
More file actions
Latest commit
36 lines (30 loc) · 552 Bytes
/
Copy pathLinkedStack.h
File metadata and controls
36 lines (30 loc) · 552 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
36
#ifndef STACK_LINKEDSTACK_H
#defineSTACK_LINKEDSTACK_H
#include<list>
template <classT>
classLinkedStack: publicStack<T> {
public:
voidpush (const T& val);
T pop ();
boolempty();
private:
std::list<T> stack;
};
template<classT>
void
LinkedStack<T>::push(const T &val) {
stack.push_back(val);
}
template<classT>
T
LinkedStack<T>::pop() {
T v = stack.back();
stack.pop_back();
return v;
}
template<classT>
bool
LinkedStack<T>::empty() {
return stack.empty();
}
#endif//STACK_LINKEDSTACK_H