I get an error when I try to compile my code. I can't figure it out. It says it's not declared but I think it is declared.
//
//
// This menu-driven program is used to allow the user to choose
// an application to be executed.
//
//
//
#include <string>
#include <cstdlib>
#include <iostream>
//
using namespace std;
//
// This class represents a string that can be tested to see if it is a palindrome
class PString :: public string
{
public:
//
// THE FUNCTION PROTOTYPE FOR "isPalindrome"
// THE FUNCTION RETURNS A BOOLEAN DATA VALUE
// THE FUNCTION PARAMETER LIST IS EMPTY
void bool isPalandrome();
//
// MAKE "PString(string s)" A DERIVED CLASS
// FROM THE BASE CLASS "string(s)"
PString(string s)
{
}
};
// Determines whether this string is a palindrome.
//
// DECLARE THE FUNCTION HEADER FOR "isPalindrome"
// THE FUNCTION RETURNS A BOOLEAN DATA VALUE
// THE FUNCTION PARAMETER LIST IS EMPTY
// USE A SCOPE RESOLUTION OPERATOR
class PString::isPalindrome(bool)
{
int lower = 0; // Start at beginning of string
int upper = length()-1; // Start at end of string
//
// IS A "while" LOOP THAT THE CONDITION
// IS "lower" IS LESS THAN "upper"
while (lower < upper)
{
if ((*this)[lower] != (*this)[upper])
{
// Found a mismatch
return false;
}
//
// INCREMENT "lower"
lower++
upper--;
}
// No mismatch found, so is palindrome
return true;
}
//
//
// start main()
int main()
{
//
// DECLARE A STRING VARIABLE NAMED "str"
string str;
char again = ' ';
//
cout << "\n.\n\n";
cout << "This program uses a class to test a string"
<< "\nto see if it is a palindrome.\n\n";
//
// Request input from user
// to test a strings to see if they are palindromes.
do
{
cout << "Enter a string to test: ";
cin >> str;
// Create a PString object that will check strings
PString s(str);
// Check string and print output
if (s.isPalindrome())
cout <<"\n" << s << " is a palindrome";
else
cout << "\n" << s << " is not a palindrome";
cout << "\n\nDo you want to enter another string? (Y or N): ";
cin >> again;
cout << "\n\n"string str;
}
//
// A "while" LOOP THAT THE CONDITION
// IS DOES "again" EQUAL Y OR DOES "again" EQUAL y
while(again=='y'||again=='Y');
cout << "\n\n";
//
// system("pause");
}