Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. no match for 'operator== ' (operand types are const and 'zItem' const 'zItem'
Forum Updated to NodeBB v4.3 + New Features

no match for 'operator== ' (operand types are const and 'zItem' const 'zItem'

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hamzan Martinez
    wrote on last edited by Hamzan Martinez
    #1

    Good evening QT userbase.

    I have the following piece of code:

    struct zItem {
        QString Title;
        QString FileName;
    
    public:
        bool operator==(zItem item)
        {
            if (Title    == item.Title    &&
                FileName == item.FileName)
            {
                return true;
            }
            return false;
        }
    };
    
    QVector<QVector<zItem>> itemList;
    QVector<QVector<zItem>> itemList2;
    if (itemList == itemList2)
    {
    // private code
    }
    

    I receive the error "no match for 'operator== ' (operand types are const and 'zItem' const 'zItem'".

    I do not understand why I get this error or how to solve it. Can anyone help shed some light?

    1 Reply Last reply
    0
    • nageshN Offline
      nageshN Offline
      nagesh
      wrote on last edited by
      #2

      @Hamzan-Martinez you have missed const at the end, it should work now

      bool operator == (zItem item) const
      
      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved