9.3k views
2 votes
Write a class definition for a student. It should have student ID and student name. Include the mutator and accessor functions for both of those member variables.

1 Answer

2 votes

Answer:

class student {

private:

int studentID;

string student_name;

public:

int getID() // accessor...

{

return studentID;

}

string getname() //accessor...

{

return student_name;

}

void setvalues(int ID,string name) //mutator..

{

studentID=ID;

student_name=name;

}

};

Step-by-step explanation:

The above written class is in C++.I have created two private members student_ID and student_name.Two accessor function getname and getID and one mutator function setvalues and these functions are public.