Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "std_lib_facilities_4.h"
- struct Student{
- private:
- string last_name;
- int UIN;
- double GPA;
- public:
- Student(string l_name, int number, double grade): last_name(l_name), UIN(number), GPA(grade){}
- string getlast_name() const{return last_name;}
- int getUIN() const {return UIN;}
- double getGPA() const{return GPA;}
- };
- istream &operator >>(istream &in, Student &student){
- string last_name;
- int UIN;
- double GPA;
- char c1, c2;
- in>>last_name>>UIN>>GPA;
- student = Student{last_name, UIN, GPA};
- return in;
- }
- ostream &operator <<(ostream &out, const Student &student){
- return out<<student.getlast_name()<<" "<<student.getUIN()<<" "<<student.getGPA();
- }
- int main(){
- vector<Student>vi;
- int i = 0;
- ifstream readStudent;
- readStudent.open("student.txt");
- while (readStudent.good()){
- readStudent>>vi[i];
- ++i;
- }
- for(i=0; i<3; i++){
- cout<<vi[i]<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement