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 7571297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:38:28+00:00 2026-05-30T15:38:28+00:00

I am writing a callback function which has a reference to a int vector

  • 0

I am writing a callback function which has a reference to a int vector passed to it in a structure. When I try to access an element in the vector using subscript operator[], Intellisense indicates that the == cannot compare the two elements specifically the error is
error C2678: binary ‘==’ : no operator found which takes a left-hand operand of type ‘std::vector<_Ty>’ (or there is no acceptable conversion). But when using at() function there is no problem.

//body of call back function
searchInfo* argVal = (searchInfo*) Parameter;
for(int i = argVal->inclStartPos; i < argVal->exclEndPos; ++i){
    if(argVal->numVector[i] == argVal->searchNum)//problem here
        argVal->result = true;
//this is the structure passed through pointer

struct searchInfo{
int inclStartPos;
int exclEndPos;
vector<int>* numVector; 
int searchNum;
bool result;
};

Since the [] operator and at() function of a vector work almost(the difference doesn’t matter here) in the same manner, why the error?

  • 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-30T15:38:29+00:00Added an answer on May 30, 2026 at 3:38 pm

    Actually, you are comparing vector < int > with int, since the field numVector has type

    vector<int>*
    

    Simply speaking, you’ve declared an array of vector’s.
    Operator [] will return a value of type vector.

    Probably you have misspelled the declaration. Maybe you wanted to declare numVector as follows:

    vector<int> numVector;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an application, and I'm currently using libcurl. The libcurl callback function works
I am writing an Ajax application which uses a callback function to add a
I'm writing a callback function for the FB.Connect.showPermissionDialog() function which accepts permissions and an
I'm writing a function add_event as the following shows: function add_event(o, event_type, callback, capture){
I'm working on writing a FileSystemWatcher using Mono but for some reason the callback
I'm writing a google chrome extension that uses chrome.pageCapture.saveAsMHTML(object details, function callback) function callback
I am requesting with AJAX (using jQuery) a tag which contains a Javascript function
Background I am writing an application which has two distinct functions. Load a GPX
I'm experiencing an access violation error when I try to call non static function.
I am writing an custom callback function in Fortran for a piece of software

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.