Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Stack.h"
- #include <iostream>
- #include <string>
- using namespace std;
- Stack::Stack(int size) :
- m_size(size)
- {
- m_list = new int[m_size];
- }
- void Stack::push(int elem) {
- m_list[getQuantity()] = elem;
- m_quantity++;
- }
- void Stack::pop() {
- m_list[getQuantity() - 1] = 0;
- m_quantity--;
- }
- int Stack::peek() {
- return m_list[getQuantity() - 1];
- }
- bool Stack::isEmpty() {
- if (getQuantity() == 0) {
- return true;
- }
- return false;
- }
- void Stack::makeEmpty() {
- while (!isEmpty()) {
- pop();
- }
- }
- int Stack::getSize() {
- return m_size;
- }
- int Stack::getQuantity() {
- return m_quantity;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement