How to call struct from separate function? <pre><code>#include &lt;iostream&gt; #include &lt;cmath&gt; using namespace std; struct workers{ int ID; string name; string lastname; int date; }; bool check_ID(workers *people, workers &amp;guy); void check_something(workers *people, workers &amp;guy, int&amp; i); int main() { workers people[5]; for(int i = 0; i &lt; 5; i++){ cin &gt;&gt; people[i].ID; cin &gt;&gt; people[i].name; cin &gt;&gt; people[i].lastname; cin &gt;&gt; people[i].date; if(check_ID(people, people[i]) == true) cout &lt;&lt; "True" &lt;&lt; endl; else cout &lt;&lt; "False" &lt;&lt; endl; check_something(people, people[i], i); } return 0; } bool check_ID(workers *people, workers &amp;guy){ for(int i = 0; i &lt; 5; i++){ if(people[i].ID == guy.ID) return true; break; } return false; } void check_something(workers *people, workers &amp;guy, int&amp; i){ check_ID(people, guy[i]); } </code></pre> <p>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: <code>error: no match for 'operator[]' in guy[i]</code> on this line : <code>check_ID(people, guy[i]);</code> in the function <code>check_something</code>. </p>