I have the following code that tests a string to see if it is a palindrome. The only error I am getting is when I try to pass each character to the queue and stack. Is there another way to pass it to each?
//Implement the palindrome-recognition algotithm described in "Simple Applications of the ADT Queue"
#include <iostream>
#include <queue>
#include <stack>
#include <string>
using namespace std;
void isPal(string);
void isPal(string s)
{
queue <string> aQueue;
stack <string> aStack;
for(int i = 0; i < s.length(); i++)
{
aQueue.push(s[i]); //problem is right
aStack.push(s[i]); // here
}
bool charEqual = true;
while(!aQueue.empty() && charEqual ==true)
{
if(aQueue.front() == aStack.top())
{
aQueue.pop();
aStack.pop();
}
}
// return charEqual;
if(charEqual == 0)
{
cout << "Yep its a palindrome" << endl;
}
else
cout << "Nope, its not a palindrome" << endl;
}
int main ()
{
string input;
cout << "Enter the string: ";
cin >> input;
isPal(input);
return 0;
}