-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.cpp
More file actions
49 lines (40 loc) · 1.01 KB
/
class.cpp
File metadata and controls
49 lines (40 loc) · 1.01 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
Ramamurthy Sundar
class.cpp
Implementation for class.h. See comments on function definitions.
*/
#include "class.h"
//top of stack
template <typename T>
T StudentStack<T>::front() {
return sDeque.front();
}
//bottom of stack
template <typename T>
T StudentStack<T>::back() {
return sDeque.back();
}
//tell number of elements in stack
template <typename T>
int StudentStack<T>::size() {
return sDeque.size();
}
//tell whether stack is empty or not
template <typename T>
bool StudentStack<T>::isEmpty() {
return sDeque.empty();
}
//push to the front of the deque (top of stack)
template <typename T>
void StudentStack<T>::push(const T& val) {
sDeque.push_front(val);
}
//remove from the front of the deque (top of the stack)
template <typename T>
void StudentStack<T>::pop() {
if (!sDeque.empty()) sDeque.pop_front();
}
//potential types passed into the class
template class StudentStack<int>;
template class StudentStack<std::string>;
template class StudentStack<char>;