Array as a global variable? Rethink about that. Globals, like dark side of the Force, seem quick and easy but trap you unnecessarily.
You do set the values for each Student with a constructor. Does that warrant separate setName and setGPA? Can the name of a student change later?
Overridden output operator for Student would be a nice addition though. To be able to write:
1 2 3
|
for ( const auto & student : CIS054 ) {
std::cout << student << '\n';
}
|
Or perhaps something like:
1 2 3 4 5 6 7
|
for ( const auto & student : CIS054 ) {
if ( student.hasValidID() ) {
std::cout << student << '\n';
} else {
std::cout << "fake student\n";
}
}
|
The point is that the Student may have whatever it has, but it can tell (with booleans) about itself and the caller, like main(), can opt to ask questions and act based on the answers.
Alternatively, member functions can write to std::cout as a
side-effect. Think what happens, if the constructor writes and the global array is initialized with poor students ...
PS. "1st character of name must be A-Z" does allow a "valid student":
Anne-maRie von kaRajan?