SFML community forums
Help => Window => Topic started by: Kernelpanic on June 01, 2008, 10:47:37 pm
-
#ifndef SFEKE_OPERATOR_LESS
#define SFEKE_OPERATOR_LESS
namespace sf
{
bool operator<(const Event::KeyEvent& a, const Event::KeyEvent& b)
{
if(static_cast<int>(a.Code) < static_cast<int>(b.Code))
return true;
if(static_cast<int>(a.Code) > static_cast<int>(b.Code))
return false;
if(a.Alt < b.Alt)
return true;
if(a.Alt > b.Alt)
return false;
if(a.Control < b.Control)
return true;
if(a.Control > b.Control)
return false;
if(a.Shift < b.Shift)
return true;
return false;
}
};
#endif
I want to use an Event::KeyEvent as Keytype in a multimap.
So I have defined this operator<.
But I get this g++-Link-Error:
/home/Jonathan2/Desktop/C++/Linuwokakerox/src/Utils.cpp:35: multiple definition of `sf::operator<(sf::Event::KeyEvent const&, sf::Event::KeyEvent const&)'
What could I do?
-
Define your function in a cpp file, or make it inline if you want to keep it in a header.
-
Yeah, it works fine!
Thank you, it is a very nice forum!