forked from BitSails/list-adt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStackV.cpp
More file actions
71 lines (39 loc) · 760 Bytes
/
StackV.cpp
File metadata and controls
71 lines (39 loc) · 760 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "StackV.h"
#include <iostream>
#include <vector>
#include <stack>
#include <string.h>
using namespace std;
int Stack::size(){
return data.size();
}
int Stack::top(){
int track = 0;
if(data.size() <= 0){
cout << "Stack is empty!" << endl;
return -1;
}else{
for(int x = 0; x < data.size()-1; x++){
track++;
}
cout << "Current top of Stack: " << data[track] << endl;
return data[track];
}
}
void Stack::push(int k){
data.push_back(k);
}//end block
void Stack::pop(){
if(data.size() <= 0){
cout << "Stack is emtpy!" << endl;
}else{
data.pop_back();
}
}
void Stack::clear(){
int loc = 1;
while(loc != data.size()){
data.pop_back();
loc++;
}
}