// Ch. 14 Demo #5
// Purpose - to illustrate the use of a vector of structs
#include <iostream.h>
#include "M:\C++ Programming\AP classes\apvector.h"
#include "M:\C++ Programming\AP classes\apstring.h"
struct Student
{
apstring name;
int grade;
double gpa;
Student();
};
int main()
{
apvector <Student> wyo(5); // student at Wyomissing high school
int i = 0;
for (i = 0; i < 5; i++)
{
cin >> wyo[i].name;
cin >> wyo[i].grade;
cin >> wyo[i].gpa;
}
for (i = 0; i < 5; i++)
{
cout << "Student #" << i + 1 << ": " << wyo[i].name << '\t'
<< wyo[i].grade << '\t' << wyo[i].gpa << endl;
}
return 0;
}// end of main
Student::Student():name("none"), grade(0), gpa(0.0)
// default construct for Student struct initializing member variables with
// an initializer list
{
}