Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- class Student
- {
- public:
- Student(string fname, string lname, double gpa) :
- first_name(fname), last_name(lname), GPA(gpa)
- {}
- void print() const
- {
- cout << first_name << ' ' << last_name << ' ' << GPA << endl;
- }
- private:
- string first_name;
- string last_name;
- double GPA;
- };
- vector<Student> read_student_info(size_t n)
- {
- vector<Student> students;
- for (size_t i = 0; i < n; ++i)
- {
- string fname, lname;
- double gpa;
- cin >> fname >> lname >> gpa;
- Student student(fname, lname, gpa);
- students.push_back(student);
- }
- return students;
- }
- int main()
- {
- size_t n;
- cin >> n;
- vector<Student> students = read_student_info(n);
- for (auto& student : students)
- student.print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement