#include <iostream>
using namespace std;
#include <conio.h>
class stde
{
int rnumber;
string name;
public:
stde(){};
stde(int rnumber, string name)
{
this->rnumber = rnumber;
this->name = name;
}
void printdata()
{
cout << "rollnumber : " << rnumber << endl;
cout << "name : " << name << endl;
}
};
void getdata(stde *argu, int size)
{
int rnumber;
string name;
for (int i = 0; i < size; i++)
{
cout << "for student number " << i + 1 << endl
<< endl;
cout << "enter rollnumber: " << endl;
cin >> rnumber;
cout << "enter name: ";
cin >> name;
*(argu + i) = stde(rnumber, name);
}
}
int main()
{
int size;
cout << "enter number of students \n"
<< endl;
cin >> size;
system("cls");
stde *sptr = new stde[size];
getdata(sptr, size);
system("cls");
for (int i = 0; i < size; i++)
{
cout << "for student number " << i + 1 << " details entered were" << endl
<< endl;
(sptr + i)->printdata();
}
return 0;
}
REFRENCE LINK
No comments:
Post a Comment