I can't wrap my head around how I would implement the following code using a dynamic array. Two stacks from this class will be used to make a queue class.
I know how dynamic arrays work, but they're not exactly my strong suit. How would I make them work for this?
Code:class stack { public: static const int CAPACITY = 30; // Constructor stack () { used = 0; } // Modification Member Functions void push(const int& entry); void pop(); // Constant member functions bool empty() const { return (used == 0);} int size() const { return used; } int top() const; private: int data[CAPACITY]; // Partially filled array int used; // How much of the array is being used };



1Likes
LinkBack URL
About LinkBacks



