c++ - This struct is defined, so why does the function think it isn't? -
new c++. making simple struct/array program. why can't pass array of structs intend here?
int numgrads(); int main() { struct pupil { int id; bool isgrad; }; const size_t size = 2; pupil s1, s2; pupil students[size] = { { 123, true }, { 124, false } }; numgrads(students, size); std::cin.get(); homecoming 0; } int numgrads(student stu[], size_t size){ }
i appreciate must passing either reference or value, certainly if i've defined in main(), shouldn't getting error parameter of numgrads?
student
defined in main()
. define outside of main it's in same scope numgrads
:
struct pupil { int id; bool isgrad; }; int main() { ... }
c++ arrays parameters struct undefined
No comments:
Post a Comment