Ask Question
23 June, 03:28

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.

+2
Answers (1)
  1. 23 June, 04:44
    0
    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;

    }

    };

    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.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a class definition for a student. It should have student ID and student name. Include the mutator and accessor functions for both of ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers