From ffc0af8b2e2a62a1b22d975dc8ca7ac966adb49b Mon Sep 17 00:00:00 2001 From: Mohit Arora <32641304+mohitarora3@users.noreply.github.com> Date: Sat, 3 Oct 2020 13:35:58 +0000 Subject: [PATCH] Update stack_using_array.cpp Making the code more readable --- stack_using_array.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/stack_using_array.cpp b/stack_using_array.cpp index 069ab79..af91331 100644 --- a/stack_using_array.cpp +++ b/stack_using_array.cpp @@ -8,6 +8,7 @@ using namespace std; class stack +{ /* objective: Create a class for implementing Stack using array input parameters: none @@ -15,19 +16,19 @@ class stack 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) { @@ -77,7 +78,6 @@ int stack::pop() int stack::size() { - /* objective:to return current size of stack input parametrs:none @@ -88,7 +88,6 @@ int stack::size() int stack::peek() { - /* objective:to return top element of stack input parametrs:none @@ -206,6 +205,7 @@ int main() } cout<<"\nwant to continue (enter Y or Y) "; cin>>c; + }while(c=='y'||c=='Y');