So I have the following code in a header file named Classes.h:
#ifndef CLASSESS_H
#define CLASSESS_H
class PalindromeCheck
{
private:
string strToCheck;
string copy;
public:
PalindromeCheck(string testSubject) : strToCheck(testSubject) {} //Constructor
void Check()
{
copy = strToCheck; //Copy strToCheck into copy so that once strToCheck has been reversed, it has something to be checked against.
reverse(strToCheck.begin(), strToCheck.end()); //Reverse the string so that it can be checked to see if it is a palindrome.
if (strToCheck == copy)
{
cout << "The string is a palindrome" << endl;
return;
}
else
{
cout << "The string is not a palindrome" << endl;
return;
}
}
};
#endif
And now I have the following code in a source file:
#include <iostream>
#include <string>
#include <algorithm>
#include "Classes.h"
using namespace std;
int main()
{
PalindromeCheck firstCheck("ATOYOTA");
firstCheck.Check();
return 0;
}
When I compiled this code using the Visual C++ Compiler, I got a ton of errors messages that all stemmed from these first four:
'strToCheck': unknown override specifier missing type specifier - int assumed. 'copy': unknown override specifier missing type specifier - int assumed.
I tried adding in #include <string>
into the header file and recompiled it but it did absolutely nothing. This confuses me because I thought I could use a string as a datatype, but apparently not in a class? It would be great if someone could help me out because I don't know why my code isn't working.