Ask 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 those member variables.

+5
Answers (1)
  1. 7 February, 09:32
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers