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

  • SEARCH
  • Home
  • 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 8822605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:08:51+00:00 2026-06-14T06:08:51+00:00

What i want to do is to match allow user to enter for example

  • 0

What i want to do is to match allow user to enter for example ID and match that ID with some vector and print it. Here is how my class looks like. (I am trying to do an inventory program).

class Item{
private:
  string month;
  string name;
  int ID;
  int actual_qunatity;

public:
  void print()const;
  void report();
  void getdata();
  void setname (string itemname){name=itemname;}
  void setID(int setID){ID=setID;}
};
class Inventory{
public:
  void print2()const;
  void report();
  void getdata();
  void sale();
private:
      vector<Item>items;
};

after adding elements to the vector i want to find some element in the vector and print it. here is

void Inventory::sale(){                                                                                                                                                               
  int ID;
  cout<<"Enter ID ";
  cin>>ID;
  vector<Item>::const_iterator it;
  it=find(items.begin(), items.end(), ID);
  ++it;
}

but i get an error: no matching function for call to ‘find(std::vector::iterator, std::vector::iterator, int&)’

  • 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-06-14T06:08:52+00:00Added an answer on June 14, 2026 at 6:08 am

    Yes, this is because you have a vector of Item objects and you are telling it to look for an integer. You need to either change your design or simply use a for loop and manually do the check on each object somewhat like this:

    std::vector<Item>::const_iterator it;
    for(it = items.begin(); it != items.end(); it++) {
        if (it->ID == ID) {
            // this is your element
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm implementing an autocomplete that will allow a user to enter in partial text
I want to match expressions that begin with ${ and end with } in
I want to match strings like those below. abc|q:1,f:2 cba|q:1,f:awd2,t:3awd,h:gr I am using php
I want to match all lines that have any uppercase characters in them but
I want to match links like <a href=mailto:my@email.com>foo</a> , but this doesn't work only
I want to validate a jtextfield as user inputs a price of some item.
I want to write a function that allows users to match data based on
How do I allow the user to re enter the customerID number if it
I have a model hierarchy that looks something like this: Office | +-- Person
I want to allow my users to toggle the current user theme between Aero

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.