Vector Operator issue

  • 13 years ago
    I've created a class that I want to use as a vector.
    Everything seems to be fine except that I'm running into a compiling error:
    error C2678: binary '<' : no operator found which takes a left-hand operand of type 'const std::string' (or there is no acceptable conversion)

    I'm a little lost on how to fix it.

    Thanks In advance:

    class part_info
        string part_no;
        string raw_qty;
        int qty;
        int ref;
        const operator<(part_info&) const;

        part_info() : part_no(""), raw_qty(""), qty(0), ref(0) {}
        part_info(string NewPartNo, string NewRawQty, int NewQty, int NewRef) : part_no(NewPartNo), raw_qty(NewRawQty), qty(NewQty), ref(NewRef) {}

    bool operator<(const part_info& x, const part_info& y)
        return x.part_no < y.part_no;

    typedef vector<part_info> NAMEVECTOR;

  • 13 years ago


    Do you have included the 'string' class ?

    #include <string>
    using std::string;

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Better train people and risk they leave – than do nothing and risk they stay.” - Anonymous