The DynIntStack and Dyn IntQueue classes shown in this chapter are abstract data types using a dynamic stack and dynamic queue, respectively. The classes do not cur- rently test for memory allocation errors. Modify the classes so they determine whether new nodes cannot be created by handling the bad_alloc exception. here is the extention.h file please use it #ifndef DYNINTQUEUE_H #define DYNINTQUEUE_H
for c++ thank you
Error Testing
The DynIntStack and Dyn IntQueue classes shown in this chapter are abstract data types using a dynamic stack and dynamic queue, respectively. The classes do not cur- rently test for memory allocation errors. Modify the classes so they determine whether new nodes cannot be created by handling the bad_alloc exception.
here is the extention.h file please use it
#ifndef DYNINTQUEUE_H
#define DYNINTQUEUE_H
class DynIntQueue
{
private:
// Structure for the queue nodes
struct QueueNode
{
int value; // Value in a node
QueueNode *next; // Pointer to the next node
};
QueueNode *front; // The front of the queue
QueueNode *rear; // The rear of the queue
int numItems; // Number of items in the queue
public:
// Constructor
DynIntQueue();
// Destructor
~DynIntQueue();
// Queue operations
void enqueue(int);
void dequeue(int &);
bool isEmpty() const;
bool isFull() const;
void clear();
};
#endif
the second file
// Specification file for the DynIntStack class
#ifndef DYNINTSTACK_H
#define DYNINTSTACK_H
class DynIntStack
{
private:
// Structure for stack nodes
struct StackNode
{
int value; // Value in the node
StackNode *next; // Pointer to the next node
};
StackNode *top; // Pointer to the stack top
public:
// Constructor
DynIntStack()
{ top = nullptr; }
// Destructor
~DynIntStack();
// Stack operations
void push(int);
void pop(int &);
bool isEmpty();
};
#endif

Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images









