Description Resource Path Location Type
from this location Shape.cpp /Asteroids line 27 C/C++ Problem
from this location Shape.cpp /Asteroids line 28 C/C++ Problem
from this location Shape.cpp /Asteroids line 30 C/C++ Problem
from this location Shape.cpp /Asteroids line 31 C/C++ Problem
from this location Shape.cpp /Asteroids line 33 C/C++ Problem
invalid use of member ‘sf::Rect<float>::Bottom’ in static member function Asteroids line 115, external location: /usr/include/SFML/Graphics/Rect.hpp C/C++ Problem
invalid use of member ‘sf::Rect<float>::Left’ in static member function Asteroids line 112, external location: /usr/include/SFML/Graphics/Rect.hpp C/C++ Problem
invalid use of member ‘sf::Rect<float>::Right’ in static member function Asteroids line 114, external location: /usr/include/SFML/Graphics/Rect.hpp C/C++ Problem
invalid use of member ‘sf::Rect<float>::Top’ in static member function Asteroids line 113, external location: /usr/include/SFML/Graphics/Rect.hpp C/C++ Problem
make: *** [Shape.o] Error 1 Asteroids line 0 C/C++ Problem
from this location Shape.cpp /Asteroids line 32 C/C++ Problem
I'm not sure why this is happening, I don't have much experience with static member functions, but I'm pretty sure I should be using it.
I'm using the latest Eclipse CDT from eclipse.org with Ubuntu 9.04.
Static member functions are really global functions, just inside the class's namespace. That is, they don't have a 'this' pointer and therefore can't access any other members of the class (except for other static members).
This is the code that's the trouble:
1 2 3 4 5 6 7
Rect.Right = Left + Width;
Rect.Bottom = Top + Height;
Rect.AddPoint(Left, Top);
Rect.AddPoint(Right, Top);
Rect.AddPoint(Right, Bottom);
Rect.AddPoint(Left, Bottom);
Left/Top/Right/Bottom here are all referring to this->Left, this->Top, etc. Except you don't have a this pointer because the function is static.
I'm going to assume all this code is suppose to use 'Rect'... therefore you'd need to change it to: