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?