Posts

Showing posts with the label isFull operation

C++ class that implements a “stack” data structure for storing floating-point values. Required methods: Push, Pop, isEmpty, and isFull.

/*  * pshrestha_a2.cpp  *  *  *      Created on: Nov 7, 2010  * Write a C++ class that implements a “stack” data structure for storing floating-point values. Required methods: Push, Pop, isEmpty, and isFull. Feel free to come up with any additional methods you think a programmer would find useful. Implement your “stack” object using a singly linked list. Write an associated “driver” C++ program that demonstrates the use of your “stack” class.  */ #include <iostream> #include <cctype> #include <iomanip> using namespace std; const int MAX_ELEMENTS = 10; // Maximum Number of nodes our stack supports. struct Stack_Node { // Structure for the node containing a value and the next node. double Value; struct Stack_Node* Next; }; class Stack { private: struct Stack_Node* p; // Current struct Stack_Node* top; int nodeCounter; // To count the nodes. public: Stack(); bool push(double&); ...