Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include "std_lib_facilities_4.h"
  2.  
  3. struct Student{
  4.  
  5. private:
  6. string last_name;
  7. int UIN;
  8. double GPA;
  9.  
  10. public:
  11.  
  12. Student(string l_name, int number, double grade): last_name(l_name), UIN(number), GPA(grade){}
  13. string getlast_name() const{return last_name;}
  14. int getUIN() const {return UIN;}
  15. double getGPA() const{return GPA;}
  16.  
  17. };
  18.  
  19. istream &operator >>(istream &in, Student &student){
  20. string last_name;
  21. int UIN;
  22. double GPA;
  23. char c1, c2;
  24. in>>last_name>>UIN>>GPA;
  25. student = Student{last_name, UIN, GPA};
  26. return in;
  27. }
  28.  
  29. ostream &operator <<(ostream &out, const Student &student){
  30. return out<<student.getlast_name()<<" "<<student.getUIN()<<" "<<student.getGPA();
  31. }
  32.  
  33. int main(){
  34. vector<Student>vi;
  35. int i = 0;
  36.  
  37. ifstream readStudent;
  38. readStudent.open("student.txt");
  39. while (readStudent.good()){
  40. readStudent>>vi[i];
  41. ++i;
  42. }
  43.  
  44. for(i=0; i<3; i++){
  45. cout<<vi[i]<<endl;
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement