Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
42 lines (37 loc) · 788 Bytes

File metadata and controls

42 lines (37 loc) · 788 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.