-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray of Objects.cpp
More file actions
58 lines (48 loc) · 1.17 KB
/
Copy pathArray of Objects.cpp
File metadata and controls
58 lines (48 loc) · 1.17 KB
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
49
50
51
52
53
54
55
56
57
58
#include <iostream>
using namespace std;
//Array of Objects
class Student{
public:
string name, u_id;
float cgpa;
int age;
Student(){
name = "";
u_id = "";
cgpa = 0;
age = 0;
}
void inputDetails(int i){
cout << "Enter details for student " << i << endl;
cout << "Name: ";
cin >> name;
cout << "UID: ";
cin >> u_id;
// getline(cin, u_id);
cout << "CGPA: ";
cin >> cgpa;
cout << "Age: ";
cin >> age;
}
static void displayStudents(Student students[], int n){
cout << "\nName\t\tUID\t\tCGPA\tAge\n";
for(int i = 0; i < n; i++){
cout << students[i].name << "\t\t"
<< students[i].age << "\n";
}
}
};
int main(){
int n;
cout << "Enter number of students: ";
cin >> n;
Student students[n];
// Input process details
// for (int i = 0; i < n; i++) {
// students[i].inputDetails(i + 1);
// }
// Student::displayStudents(students, n);
cout << students[0].u_id;
// cout << students[0].age;
return 0;
}