Question: My assignment: You are asked to write an object-oriented program in C++ that determines a sequence of characters whether it is a palindrome. Your program
My assignment: You are asked to write an object-oriented program in C++ that determines a sequence of characters whether it is a palindrome. Your program should ask the user to enter a word, and then tell the user whether or not that word is a palindrome. Your program doesn't need to determine whether or not the word is in the English language. But you can assume that the word is made up of lower-case letters only, and that it is no more than 20 letters long. You may use the above abstract classes in various places in your program such as the member functions reads forward, reads backward, or enters.Please submit the class diagram for your program, a list of your programs, the output (generated text) of your programs, and the Makefile(s)
So, I try to do it using Inheritance, but my final error : "Undefined symbols for architecture x86_64: "Queue::check(std::__1::basic_string
```main.cpp
#include
#include "stack.h" #include "unit.h" #include "queue.h"
#include
using namespace std;
int main() { const int MAX_LETTERS = 20; string word;
cout << "Please enter a word: "<< endl; cin >> word; Queue queue1;
if (queue1.check(word)) cout << " is a palindrome." << endl; else cout << " is not a palindrome." << endl;
return 0; }
```
queue.cpp
#include
#include "stack.h" #include "unit.h" #include "queue.h"
#include
using namespace std;
Queue::Queue() { unsigned h, t, l; char q[100]; }
bool Queue::compare(string word) {
bool is_palindrome = true; int length = strlen(word);
for (int i = length - 1; i >= 0; i--){ char next_item = serve(); if (next_item != word[i]){ is_palindrome = false; } }
return is_palindrome; };
bool Queue::check(string word){ bool is_palindrome = true;
int length = strlen(word);
create_queue(); for (int i = 0; i < length; i++){ enqueue(h, t, l, q, word[i]); }
return compare(word) }
void Queue::enqueue(char std_element){ //requires: create_queue() is already executed and l < qsize //results: std_element is the most recently arrived element of the queue h--; l++; q[h] = std_element; }
char Queue::serve(){ //requires: create_queue() is already executed and 0 < l //results: the longest waiting element enqueued onto the queue is served and it is no longer on the queue q[] t--; return q[t]; }
void Queue::create_queue(){ //results: the linear data structure, queue, is initialized (or created) h = 100; t = 100; l = 0; }
```
```
queue.h
#ifndef Queue_h #define Queue_h
#include "unit.h"
#include
class Queue : public Unit { public: bool compare(std::string); bool check(std::string); void enqueue(char); char serve(); void create_queue(); };
#endif
```
```
stack.cpp
#include
#include "stack.h" #include "unit.h" #include "queue.h"
#include
using namespace std;
bool Stack::compare(string word) {
bool is_palindrome = true; int length = strlen(word);
for (int i = length - 1; i >= 0; i--){ char next_item = serve(); if (next_item != word[i]){ is_palindrome = false; } }
return is_palindrome; };
bool Stack::check(string word){ bool is_palindrome = true;
int length = strlen(word);
create_stack); for (int i = 0; i < length; i++){ enqueue(h, t, l, q, word[i]); }
return compare(word) }
void Stack::enqueue (char input) { top = input; userStack[length]=input; length++; }
char Stack::serve () { char tempTop=top; top=userStack[length]; delete userStack[length]; length--; return tempTop; }
```
```
stack.h
#ifndef Stack_h #define Stack_h
#include "unit.h"
#include
class Stack : public Unit { public: bool compare(std::string); bool check(std::string); void enqueue(char); char serve(); void create_stack(); };
#endif
```
```
unit.cpp
#include
#include "stack.h" #include "unit.h" #include "queue.h"
#include
using namespace std;
bool Unit::compare(string word) { bool is_palindrome = true; int length = strlen(word);
for (int i = length - 1; i >= 0; i--){ char next_item = serve(); if (next_item != word[i]){ is_palindrome = false; } }
return is_palindrome; }
```
unit.h
#ifndef Unit_h #define Unit_h
#include
class Unit { public: bool compare( std::string); };
#endif
```
Could you help me, please.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
