I am giving you the skeleton of the application, you have to fill the details, but then you have to know the
C++
programming language.
#include <iostream>
#include <vector>
using namespace std;
class Student
{
int roll, year;
string name, depart, crs;
public:
Student();
Student( int roll, string name, string depart, string crs, int year);
friend ostream & operator << (ostream &, const Student & );
friend istream & operator >> (istream &, Student & );
};
int main()
{
vector<Student> student;
for (size_t n=0; n<2; ++n)
{
Student s;
cout << "please enter the details of the student " << n << "\n";
cin >> s;
student.push_back(s);
}
for ( const auto & s : student )
cout << s << "\n";
}
Student::Student():
roll(-1)
{
}
Student::Student( int roll, string name, string depart, string crs, int year):
roll(roll), year(year), name(name), depart(depart), crs(crs)
{
}
ostream & operator << (ostream & os, const Student & s)
{
os << s.roll << ", " << s.name << ", " << s.depart << ", " << s.crs << ", " << s.year;
return os;
}
istream & operator >> (istream & is, Student & s)
{
is >> s.roll >> s.name >> s.depart >> s.crs >> s.year;
return is;
}