I'm suppost to display my entries by overloading the "<<" operator using friend functions. I can currently do:
Code:
Student Stud1("Williams","Jon","22222",4,5);
cout<<Stud1;
and everything works. However, all my entries are stored in an array(actually two but i will only refer to one since they are basically the same).
So i was outputting the entries like:
Code:
cout<<endl<<Array1[A_Pos2].getFirst_Name();
cout<<endl<<Array1[A_Pos2].getLast_Name();
...
however, i am suppost to make use of the overloaded "<<" operator to output the entries, and I am not sure how to do this.
These are my overloaded friend functions:
Code:
header file:
friend ostream &operator<< (ostream &, Student &);
function file:
ostream &operator<<(ostream &output, Student &person)
{
output<<"First Name: "<<person.getFirst_Name()<<endl;
output<<"Last Name: "<<person.getLast_Name()<<endl;
output<<"Phone Number: "<<person.getPhone_Number()<<endl;
output<<"GPA: "<<person.GPA<<endl;
output<<"Hours: "<<person.Hours<<endl;
return output;
}
I'm not sure how to output the entries in the array using the overloaded operator. I'm thinking it would be something like:
Code:
cout<<Array1[A_Pos2];
I'm not sure what to do.