The file student.hpp
contains the definition of a simple student
class.
It is common in object-orientated code to use accessor functions to access
member variables. Your goal is to modify the student
class to increase its
encapsulation.
Tasks:
-
Add a constructor taking
first
,last
andid
variables. Assign these to the class's member variables using a member initializer list. -
Add a member function
get_first_name()
which returns thefirst_name
field ofstudent
. What should the return type of this function be? Why? -
Add a
set_first_name()
member function to allow modifying the first_name field. -
In
set_first_name()
, ensure that the name saved in the member variable begins with a capital letter, followed by all lower case letters (hint: look up thestd::toupper()
andtolower()
functions) -
Add accessor functions for the
last_name
andid
fields. -
Make
student
aclass
rather than astruct
. Set the access levels of its member functions/variables appropriately. -
How can we make the output stream function work properly again?