I am getting myself deeper into trouble on a program I am working on. I strated out with only four errors and am now up to twelve (I am currently learning and working with six languages-c++,html,javascript,PHP,SQL,and c#). I think my languages are running together!
This program is from a textbook, but is NOT homeework, I am trying to write this as practice for what we are learning on classes and constructors. This asks you to write a program using a class to determine if input is a palindrome. Similar posts have been in here, but not using a class. I will be going to a tutorial next week on this, but I would like to continue to work through it in the meantime. Can someonre help me back onto track.
#include <string>
#include <iostream>
using namespace std;
//create class
class PString : public string
{
public:
PString(const string &aString);
bool isPalindrome() const;
};
//constructor
PString::PString( const string &aString ) : string( aString )
{
}
//funct to check pal
bool PString::isPalindrome() const
{string upperCase (string str)
{
for (int i = 0; i < str.size(); i++)
if(islower(str[i]))
str[i] = toupper(str[i]);
return str;
}
bool checkPalindrome(string str)
{
int n = str.size();
for (int i=0; i<str.size()/2;i++)
if (str[i] !=str[n-1-i])
return false;
return true;
}
int main()
{
string str;
cout << "This program is a palindrome-testing program. Enter a string to test:\n";
cin >> str;
// Create a PString object that will check strings
PString s(str);
// Check string and print output
if (s.isPalindrome())
{
cout << s << " is a palindrome";
}
else
{
cout << s << " is not a palindrome";
}
cout << endl;
system("pause");
return 0;
}