This program is supposed to check if a string is a palindrome by using only one variable and any number of stacks. It is giving me a number of error messages relating to overloaded functions, but I don't see where I overloaded it. Or did I declare the stacks wrong? I commented in the error messages after the lines of code they referred to. Thanks!
int main()
{
stack <char> stackA;
stack <char> stackB;
stack <char> stackC;
char avariable;
cout << "Enter a string: ";
avariable = cin.get();
while(avariable != '\n')
{
if(avariable != ' ')
{
stackA.push(avariable);
stackB.push(avariable);
avariable = cin.get();
}}
stackC.push('$');
while(!stackB.empty())
{
avariable = stackB.top; //error, cannot resolve overloaded function 'top' based on conversion to type 'char'
stackC.push(avariable);
stackB.pop; //statement cannot resolve address of overloaded function
}
avariable = '$';
stackC.push('$');
while(!stackA.empty())
{
if(avariable == stackC.top) //invalid operands of type 'char' and <unresolved overloaded function type>' to binary 'operator=='
{
avariable = stackA.top; //cannot resolve overloaded function 'top' based on conversion to type 'char'
stackA.pop; //cannot resolve address of overloaded function
stackC.pop; //cannot resolve address of overloaded function
}
else
{
cout << "The string of characters entered is not a palindrome." << endl;
}
}
if (stackC.top == '$') //invalid operands of type 'char' and <unresolved overloaded function type>' to binary 'operator=='
{
cout <<"The string of characters entered is a palindrome." << endl;
}
}