C++ Programming Undo Stack using a Circular Buffer HELP ME!!!?

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

};

Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Helpful Social

Copyright © 2024 Q2A.ES - All rights reserved.