I am currently working on assignment for one of my classes. I am trying to construct a class, but when I try to run the program I get this error:
http://www.word(。
我制定的法典是:
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <cctype>
//#include <cmath>
//#include <fstream>
//#include <vector>
//#include <algorithm>
using namespace std;
string wordToTest;
class Word{
public:
int length;
string word;
void TestForPalindrome();
Word(string w){
word = w;
length = word.length();
}
};
void Word::TestForPalindrome(){
string testWord;
for(int i = length; i < 0; i--){
testWord += word[i];
}
if (testWord == word){
cout << word << " is a palindrome!";
} else if (testWord != word){
cout << word << " is not a palindrome";
}
}
//error happens here
void GetInput(){
cout << "enter a word:
";
cin >> Palindrome.word;
Palindrome.TestForPalindrome();
}
Word Palindrome;
int main(){
return(0);
}
the error occurs at the comment. Thanks in advance for any help on this!