New to C++. Just making a simple struct/array program. Why can’t I pass an array of structs like I intend to here?
int NumGrads();
int main()
{
struct Student {
int id;
bool isGrad;
};
const size_t size = 2;
Student s1, s2;
Student students[size] = { { 123, true },
{ 124, false } };
NumGrads(students, size);
std::cin.get();
return 0;
}
int NumGrads(Student Stu[], size_t size){
}
I appreciate that it must be something to do with passing by either reference or value, but surely if I’ve defined it in main(), I shouldn’t be getting an error with the parameter of NumGrads?
Studentis defined inmain().Define it outside of main so that it’s in the same scope as
NumGrads: