Ask Question
22 June, 05:39

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.

+4
Answers (1)
  1. 22 June, 07:29
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers