#include <iostream>
#include <cmath>
using namespace std;
struct workers{
int ID;
string name;
string lastname;
int date;
};
bool check_ID(workers *people, workers &guy);
void check_something(workers *people, workers &guy, int& i);
int main()
{
workers people[5];
for(int i = 0; i < 5; i++){
cin >> people[i].ID;
cin >> people[i].name;
cin >> people[i].lastname;
cin >> people[i].date;
if(check_ID(people, people[i]) == true)
cout << "True" << endl;
else
cout << "False" << endl;
check_something(people, people[i], i);
}
return 0;
}
bool check_ID(workers *people, workers &guy){
for(int i = 0; i < 5; i++){
if(people[i].ID == guy.ID)
return true;
break;
}
return false;
}
void check_something(workers *people, workers &guy, int& i){
check_ID(people, guy[i]);
}
This is the code I have, it's not very good example, but I quickly wrote it to represent my problem I have because my project is kinda too big. So basically, I want to call struct from a different function and I'm getting this error:
error: no match for 'operator[]' in guy[i] on this line :
check_ID(people, guy[i]); in the function check_something.
struct workers, of course you need to define it, the compiler's making it very clear.check_somethingto do?