Operator< is missing [closed]

I have an error when building a C++ project:

error11
error12

 Error  C2678   binary '<': no operator found which takes a left-hand operand of type 'const _Ty' (or there is no acceptable conversion)    SystemModels

In build output:
C:Program Files (x86)Microsoft Visual Studio19EnterpriseVCToolsMSVC.28.29910includexstddef(127,1): error C2678: binary '<': no operator found which takes a left-hand operand of type 'const _Ty' (or there is no acceptable conversion)
        with
        [
            _Ty=DisplayDot
        ]

When I try to overload the operator (as a friend function, inside the class, in .h or .cpp file, as inline and without inline), I get a bunch of "unresolved external symbol" errors.

Here is the class with operator overloading:

class DisplayDot
{
public:
    DisplayDot();
    ~DisplayDot();

    DisplayDot(Point2f point, int odOs, vector<float> contrast, bool whiteDot);

    vector<float>* GetContrastRef();
    int* GetOdOsRef();
    Point2f* GetPointRef();
    bool* GetWhiteDotRef();
    friend inline bool operator<(const DisplayDot& dd1, const DisplayDot& dd2);

private:     
    vector<float> contrast;
    int odOs;
    Point2f point;
    bool whiteDot;

};

inline bool operator<(const DisplayDot& dd1, const DisplayDot& dd2)
{
    return dd1.point.x < dd2.point.x;
}

Here are the "unresolved external" errors:

error2

Error   LNK2001 unresolved external symbol "public: void __cdecl CDisplay::paintObject(int,float,float,float)" ([email protected]@@[email protected]) SystemModels    
Error   LNK2001 unresolved external symbol "public: void __cdecl CDisplay::paintObject(int,float,float,float)" ([email protected]@@[email protected]) SystemModels    
Error   LNK2001 unresolved external symbol "public: int __cdecl CDisplay::addObject(struct StimuliObjects)" ([email protected]@@[email protected]@@Z) SystemModels    
Error   LNK2001 unresolved external symbol "public: int __cdecl CDisplay::addObject(struct StimuliObjects)" ([email protected]@@[email protected]@@Z) SystemModels    
Error   LNK2001 unresolved external symbol main SystemModels    

The worst thing is that I don’t directly need operator<, but this class is used in a std::map so it’s needed for a binary search tree, which map uses.

Source: Windows Questions C++

LEAVE A COMMENT