-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpointers.cpp
More file actions
55 lines (46 loc) · 1.08 KB
/
pointers.cpp
File metadata and controls
55 lines (46 loc) · 1.08 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
#include <iostream>
#include <string>
using namespace std;
class Student {
public:
string name;
int number;
float marks;
string specialization;
void input() {
cout << "Enter name: ";
cin >> name;
cout << "Enter number: ";
cin >> number;
cout << "Enter marks: ";
cin >> marks;
cout << "Enter specialization: ";
cin >> specialization;
}
void display() {
cout << "Name: " << name
<< ", Number: " << number
<< ", Marks: " << marks
<< ", Specialization: " << specialization << endl;
}
};
int main() {
int n;
cout << "Enter number of students: ";
cin >> n;
Student** arr = new Student*[n];
for (int i = 0; i < n; i++) {
arr[i] = new Student;
cout << "Student " << i + 1 << " details:" << endl;
arr[i]->input();
}
cout << "\nStudent list:\n";
for (int i = 0; i < n; i++) {
arr[i]->display();
}
for (int i = 0; i < n; i++) {
delete arr[i];
}
delete[] arr;
return 0;
}