Question: ` ` ` Date: dateValue Main Author: Prof. Donathan Matthew, PhD , SCJP In All Rights Reserved * * *
"Date: dateValue
"Main Author: Prof. Donathan Matthew, PhD SCJP In
All Rights Reserved
End of DO NOT modify
return ;
Implementation for the IntStach class
Constructor
This constructor creates an empty stack. The
size parameter is the size of the stack.
IntStack::IntStackint size
stackArray new intsize;
stackSize size;
top ;
Copy constructor
IntStack::IntStackconst IntStack &obj
Create the stack array.
if objstackSize
stackArray new intobjstackSize;
else
stackArray nullptr;
Copy the stackSize attribute.
stackSize obj.stackSize;
Copy the stack contents.
for int count ; count stackSize; count
stackArraycount obj.stackArraycount;
Set the top of the stack.
top obj.top;
Destructor
IntStack:: IntStack
delete stackArray;
Member function push pushes the argument onto
the stack.
void IntStack::pushint num
if isFull
cout "The stack is full.
;
else
top;
stackArraytop num;
Member function pop pops the value at the top
Member function pop pops the value at the top
of the stack off, and copies it into the variable
passed as an argument.
void IntStack::popint &num
if isEmpty
cout "The stack is empty.
;
else
num stackArraytop;
top;
Member function isFull returns true if the stack
is full, or false otherwise.
bool IntStack::isFull const
bool status;
if top stackSize
status true;
else
status false;
return status;
Member funciton isEmpty returns true if the stack
is empty, or false otherwise.
bool IntStack::isEmpty const
bool status;
if top
status true;
else
status false;
return status;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
