C++
: Create a class called Student. The class includes four data items: studentId, studenName, courseNo and enrolmentstatus. Define a constructor to get the values of the data members and a member function named void display() to display the values of the data members. Write a class driver to test your class.
#include <iostream>
using namespace std;
class Student {
private:
int studentId;
string studentName;
int courseNo;
string enrolmentstatus;
public:
Student(int studentId,string studentName,int courseNo,string
enrolmentstatus) {
this->studentId=studentId;
this->studentName=studentName;
this->courseNo=courseNo;
this->enrolmentstatus=enrolmentstatus;
}
void display()
{
cout<<studentId<<" "<<studentName<<"
"<<courseNo<<"
"<<enrolmentstatus<<endl;
}
};
int main()
{//performing a driver test by creating two object of class which
check the status of student
Student s1=Student(1,"Amar",709,"verified");
Student s2=Student(2,"Namo",809,"NotVerifed");
s1.display();
s2.display();
return 0;
}
Get Answers For Free
Most questions answered within 1 hours.