Write a main program that pushes numbers on the stack, pushing more numbers than the stack capacity, and test all the methods of the class.
This is what I have so far:
class CircStack
{
public:
CircStack(int cap); // parameter is stack capacity
void push(double d); // push new number on stack
double pop(); // remove and return a double
double peek(); // return stack top without removing
int size(); // return how many elements on stack
private:
double *data; // pointer to array of doubles
int capacity; // the size of the array
int top; // index of next open spot
int count; // number of items on stack
};
Copyright © 2024 Q2A.ES - All rights reserved.
Answers & Comments
Very cool you have a header file... Neat...
Looks like you haven't implemented a single function yet... let us know when you actually need help.
EDIT: If you make a separate question for each function I will help you out for the points. ;)