Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6019443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:25:20+00:00 2026-05-23T03:25:20+00:00

I am trying to use the find function here. For that here’s the code

  • 0

I am trying to use the “find” function here. For that here’s the code for the ‘==’ operator. But I am getting a “too many parameters for this operator function” error at the word “operator”.

Can anyone kindly help me out ? Thanks.

struct gr_log
{
   string name;
   string category;
   string description;
   float cost;
   bool operator==(const gr_log& l, const gr_log& r) const

   {
           return l.name == r.name;
  }

};

And:

vector<gr_log>::iterator it;
it = find (grocery.begin(), grocery.end(), "Sugar");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:25:21+00:00Added an answer on May 23, 2026 at 3:25 am

    A member operator only takes one argument:

    struct gr_log
    {
       string name;
       string category;
       string description;
       float cost;
       bool operator==(const gr_log& r)
       {
           return name == r.name;
       }
    };
    

    Alternatively, you could write a friend operator:

    struct gr_log
    {
       string name;
       string category;
       string description;
       float cost;
       friend bool operator==(const gr_log& l, const gr_log& r)
       {
           return l.name == r.name;
       }
    };
    

    Also, you’ll need to perform a find using an instance of gr_log because you can’t compare a gr_log with a string like you’re trying to do:

    it = find (grocery.begin(), grocery.end(), gr_log("Sugar"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use XPath to find all elements that have an element in
I'm trying to use jQuery to find the number of divs that are both
I'm trying to use the freeware Multiple Find And Replace 1.00 suggested in this
I am trying to use the jQuery CSV plugin, as documented here: http://code.google.com/p/js-tables/wiki/CSV According
I'm trying to use the Seq.generate_using function but unfortunately, I don't seem to be
Im trying to use statvfs to find free space on a file system. Here's
I'm trying to use some code that I wrote on another computer that splits
Alright, I'm having trouble getting started on this one. I'm trying to use the
I'm trying to use tasklist to find out which process is consuming more than
I'm trying to use VDMEnumProcessWOW to find all 16 bit host processes on Vista.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.