Question
I need help with my C++ homework. ALSO PLEASE LOOK AT THE END THAT'S HOW I NEED THE PROGRAM CLASS TO BE. BUT DONT COPY
I need help with my C++ homework. ALSO PLEASE LOOK AT THE END THAT'S HOW I NEED THE PROGRAM CLASS TO BE. BUT DONT COPY THAT.
Question:
Write a program which uses a stack to match left and right parentheses.
The user can enter parentheses, operands, and operators. If an operand or operator is encountered, ignore it.
Whenever a left parenthesis is found, push it. Whenever a right parenthesis is found, pop the stack and see if the input string value is paired with the popped value.
Parentheses may be of the form (), [], OR {}
Generate the appropriate error message or specify that the parentheses are properly matched
Also please use CLASS to do this, for example, look below that's what I need in the program but don't copy that
class Node char elem; Node* next // Node class // Holds the parenthesis // Pointer to the next node public: Node()h; Nodex getNext) return next; // Accesses the 'next' variable to return the 'next' value char getElem) f return elem;; // Accesses the 'firstName variable to return the 'firstName' value void SetNode (char element) { elem = element; }; // Sets the nodes private variables void SetNextNode(Nodex adding){ next = adding; }; // Sets the next node private pointer // Constructor d: // DLinkList class // Sets the start of the node linked list class Stack Node *head; public: Stack() { head NULL;}; // Sets the head to point to NULL or the end of the list bool compare (char[]); bool matching(char, char); II Tells whether parenthesises match bool empty); void push(char); void pop(); // Tells whether the sequence of the provided parenthesis is valid or invalid // Checks of the Stack is empty. Returns 'true' if the 'head' pointer variable points to NULL els // Adds the user to input the nodes // Takes out the elemode at the top/front of the staclk dStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started