CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 1999
    Posts
    121

    operator < with a "set"

    I hope someone can shed some light on how I need to define this operator to compare.

    I get this error:

    :\program files\microsoft visual studio\vc98\include\functional(86) : error C2678: binary '&lt;' : no operator defined which takes a left-hand operand of type 'const class FileToCopy' (or there is no acceptable conversion)
    c:\program files\microsoft visual studio\vc98\include\functional(86) : while compiling class-template member function 'bool __thiscall std::less&lt;class FileToCopy&gt;:perator ()(const class FileToCopy &,const class FileToCopy &) const'

    class FileToCopy //I've create dmy operator in here
    {
    private:
    File src;
    File dst;

    public:
    FileToCopy( const File &src_, const File &dst_)
    : src( src_), dst( dst_)
    {
    }
    FileToCopy()
    {
    }

    const File &GetSrc() const { return src; }
    const File &GetDst() const { return dst; }
    operator &lt; (const FileToCopy &listOfFilesToCopy);


    };

    If you require more infornmation please let me know.

    Thank you in Advance


  2. #2
    Join Date
    May 1999
    Posts
    667

    Re: operator < with a "set"

    The only thing I see that stands out is your operator &lt; declaration does not return a bool.

    HTH,
    chris


  3. #3
    Join Date
    Apr 1999
    Posts
    121

    Re: operator < with a "set"

    I've added the return boolean but I still get this error. I'm not exactly sure how this operator works. Shouldn't I be doing some logic in the operator function..Like a compare or something..


    HELP!!!

    c:\program files\microsoft visual studio\vc98\include\functional(86) : error C2678: binary '&lt;' : no operator defined which takes a left-hand operand of type 'const class FileToCopy' (or there is no acceptable conversion)
    c:\program files\microsoft visual studio\vc98\include\functional(86) : while compiling class-template member function 'bool __thiscall std::less&lt;class FileToCopy&gt;:perator ()(const class FileToCopy &,const class FileToCopy &) const'

    // TEMPLATE STRUCT less
    template&lt;class _Ty&gt;
    struct less : binary_function&lt;_Ty, _Ty, bool&gt; {
    bool operator()(const _Ty& _X, const _Ty& _Y) const
    {return (_X &lt; _Y); }
    };

    This is where the error ends up.

    Thanks


  4. #4
    Join Date
    Apr 1999
    Location
    Monterrey, Mexico
    Posts
    21

    Re: operator < with a "set"

    two guesses:
    1) try using CX:perator &lt;(const CX& x)const

    or

    2) try an external friend operator

    bool operator &lt;(const CX& lhs, const CX& rhs);



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured