SFML community forums

Help => General => Topic started by: carton83 on January 18, 2014, 02:49:42 am

Title: 'x' does not have a class type
Post by: carton83 on January 18, 2014, 02:49:42 am
I'm trying to write a simple function that moves a sprite forward if cetain conditions are met.  I've striped out everything unrelated to my problem and simplified the logic.  I know what is causing the issue and it's a lack of knowledge, but I can't find anything that definatevly explains what I am doing wrong.  So I'm hoping you guys can help.


void moveForward(sf::RectangleShape &person)
{
    if(person.getPosition.x >= 1)
    {
        //Other code
    }
}
Title: Re: 'x' does not have a class type
Post by: AlexAUT on January 18, 2014, 03:08:54 am
 
void moveForward(sf::RectangleShape &person)
{
    if(person.getPosition().x >= 1)
    {
        //Other code
    }
}


You forgot the parentheses :) . Because you are calling a function and not trying to acces a public variable.


AlexAUT
Title: Re: 'x' does not have a class type
Post by: carton83 on January 18, 2014, 03:33:53 am
Ah, thanks.  I should have caught that.

I wish GCC's error message where a bit more readable.  I shouldn't have to learn another, non-programming language just to understand GCC's messages.
Title: Re: 'x' does not have a class type
Post by: zsbzsb on January 18, 2014, 03:38:20 am
I wish GCC's error message where a bit more readable.  I shouldn't have to learn another, non-programming language just to understand GCC's messages.

Welcome to the world of C++ compiler errors  ;)

(it gets better when you are trying to help someone that is using a compiler in a language you don't even speak)
Title: Re: 'x' does not have a class type
Post by: dabbertorres on January 18, 2014, 04:01:56 am
Ah, thanks.  I should have caught that.

I wish GCC's error message where a bit more readable.  I shouldn't have to learn another, non-programming language just to understand GCC's messages.
You could try using clang (http://clang.llvm.org/). It is known to have much more informative errors than MSVC/GCC. Though it doesn't optimize as well (at least older versions used to, it may have changed). I've known several people to use clang when developing, and then switching to gcc when wanting to release.