forked from thakursaurabh1998/cpp
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathques16-1.cpp
42 lines (37 loc) · 788 Bytes
/
ques16-1.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
/* Write a program that has a class student to store the details of students in a class.*/
#include <iostream>
#include <string>
using namespace std;
class Student
{
string name;
int roll;
string section;
public:
Student(string n, string s, int r) : name(n), section(s), roll(r){}
void display()
{
cout << "Name: " << name << endl;
cout << "Section: " << section << endl;
cout << "Roll No: " << roll << endl;
}
~Student(){};
};
int main()
{
int num;
string n,s;
int r;
cout << "Enter number of students: ";
cin >> num;
Student **arr = new Student*[num];
for (int i = 0; i < num; ++i)
{
cout << "Enter Name, Section and Roll No: " << endl;
cin >> n >> s >> r;
arr[i] = new Student(n,s,r);
}
for (int i = 0; i < num; ++i)
arr[i]->display();
return 0;
}