-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcbtc.cpp
48 lines (37 loc) · 826 Bytes
/
cbtc.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Student {
public:
string name;
int age;
double gpa;
Student(string name, int age, double gpa) {
this->name = name;
this->age = age;
this->gpa = gpa;
}
};
class Records {
private:
vector<Student> students;
public:
void addStudent(Student student) {
students.push_back(student);
}
void printStudents() {
for(Student s : students) {
cout << "Name: " << s.name << ", Age: " << s.age << ", GPA: " << s.gpa << endl;
}
}
};
int main() {
Records records;
Student john("John Doe", 18, 3.5);
Student jane("Jane Smith", 17, 3.8);
records.addStudent(john);
records.addStudent(jane);
records.printStudents();
return 0;
}