Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions stack_using_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,27 @@ using namespace std;


class stack
{
/*
objective: Create a class for implementing Stack using array
input parameters: none
output value: none
description: class definition
approach: Class defines data member and member function of the stack class
*/
{
int *arr; // for dynamic array
int top;
int capacity; // checks size defined by user
public:
stack(int size = MAXSIZE); // constructor to create array dynamically
~stack(); // destructor to delete dynamically created array
void push(int &);
int pop();
int peek();
int size(); // Current size of stack
bool isEmpty();
bool isFull();
public:
stack(int size = MAXSIZE); // constructor to create array dynamically
~stack(); // destructor to delete dynamically created array
void push(int &);
int pop();
int peek();
int size(); // Current size of stack
bool isEmpty();
bool isFull();
};
stack::stack(int size)
{
Expand Down Expand Up @@ -77,7 +78,6 @@ int stack::pop()

int stack::size()
{

/*
objective:to return current size of stack
input parametrs:none
Expand All @@ -88,7 +88,6 @@ int stack::size()

int stack::peek()
{

/*
objective:to return top element of stack
input parametrs:none
Expand Down Expand Up @@ -206,6 +205,7 @@ int main()
}
cout<<"\nwant to continue (enter Y or Y) ";
cin>>c;

}while(c=='y'||c=='Y');


Expand Down