Error: Palindrome function using Bool

Hello,

I am new to using bool in c++. I am trying to make a function (is_palindrome) that tests if a word is a palindrome, which requires that it be all letters (using hasletters) and that the word is the same forwards as backwards (using ispal), and that the string s is not empty. hasletters and ispal are functions I made before, but I think the error might be in how I used bool here. The main function is_palindrome takes in the string s and bool error, but it is also a bool. Can you do this? Is there something else wrong in this code?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  bool error(s);
  {
    if (s == "")
      {return true;}
    if (hasletters(s))
     {return true;}
    if (ispal(s)) 
     {return false;}
 }
bool is_palindrome(string s, bool & error) 
  if (error(s)) 
   {return false;}
  else 
     {return true;}
}


Thank you!
If you are defining a function you do not want to use a semicolon before the brackets, and the argument needs to have a variable type, in this case bool.

Line 1: bool error(bool s)

Line 10 is also the beginning of a function definition and it's missing an opening bracket { after it.

If you would show your whole code this would be a lot easier...
Last edited on
Topic archived. No new replies allowed.