invalid use of member (did you forget the &?)

hi everyone, this is my first post, so bear with me.
this is driving me insane. im trying to write a program for Project Euler problem 4. here is the code that is giving me problems (its not complete yet)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* A palindromic number reads the same both ways.
 * The largest palindrome made from the product
 * of two 2-digit numbers is 9009 = 91 × 99.
 *
 * Find the largest palindrome made from
 * the product of two 3-digit numbers.
 *
 */

#include <iostream>
#include <sstream>
#include <string.h>

using namespace std;

bool isPalindrome(int number)
{
    string check;
    stringstream out;
    out << number;
    check = out.str();

    for (int position = 0; position < (check.length/2); position++)
    {
        if (check.at(position) == check.at(check.length - position))
        {
            return false;
        }
    }
    return true;
}

int main()
{
    isPalindrome(1234);
    return 0;
}

and the errors are

/home/nick/Euler/Euler004/main.cpp||In function ‘bool isPalindrome(int)’:|
/home/nick/Euler/Euler004/main.cpp|23|error: invalid use of member (did you forget the ‘&’ ?)|
/home/nick/Euler/Euler004/main.cpp|25|error: invalid use of member (did you forget the ‘&’ ?)|
||=== Build finished: 2 errors, 0 warnings ===|

what exactly does this error message mean and how do i fix it?

Last edited on
haha duh. i forgot the () after both check.length lol. mods can delete this if they feel like it :P
Haha - yeah got to admit I've missed that myself a few times from typing to quickly :(
Topic archived. No new replies allowed.