File tree 1 file changed +10
-10
lines changed
1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ class Stack {
14
14
public:
15
15
Stack (){}
16
16
17
- bool insert (int element) {
17
+ bool push (int element) {
18
18
if ((this ->elements * TYPE_SIZE) == sizeof (this ->arr )) {
19
19
return false ;
20
20
};
@@ -30,7 +30,7 @@ class Stack {
30
30
return false ;
31
31
}
32
32
33
- bool remove () {
33
+ bool pop () {
34
34
if (this ->isEmpty ()) {
35
35
return false ;
36
36
}
@@ -56,27 +56,27 @@ int main() {
56
56
Stack* stack = new Stack ();
57
57
58
58
// Insert Elements, then removes
59
- stack->insert (1 );
60
- stack->insert (2 );
61
- stack->insert (4 );
59
+ stack->push (1 );
60
+ stack->push (2 );
61
+ stack->push (4 );
62
62
std:: cout << stack->top () << std::endl;
63
- stack->remove ();
63
+ stack->pop ();
64
64
std:: cout << stack->top () << std::endl;
65
- stack->remove ();
66
- stack->remove ();
65
+ stack->pop ();
66
+ stack->pop ();
67
67
68
68
std::cout << " --------------------" << " \n " ;
69
69
70
70
// Try to insert beyond max size
71
71
for (int i = 0 ; i < 15 ; i++) {
72
- std::cout << stack->insert (i) << std::endl;
72
+ std::cout << stack->push (i) << std::endl;
73
73
}
74
74
75
75
std::cout << " --------------------" << " \n " ;
76
76
77
77
// Show and remove stack top element
78
78
for (int i = 0 ; i < stack->getSize (); i++) {
79
79
std::cout << stack->top () << std::endl;
80
- stack->remove ();
80
+ stack->pop ();
81
81
}
82
82
}
You can’t perform that action at this time.
0 commit comments