Your task is to implement the Student
class in EXERCISE.h
You do not need to look at any other source code to complete the tasks. In
fact, unless you are familiar with template metaprogramming, you will find both
main.cpp
and private/Checker.h
to be extremely confusing.
Implement the following:
This covers writing a basic implementation.
Your class should have two std::string data members:
firstName
- an std::string
holding the student's first name
lastName
- an std::string
holding the student's last name
both of these members should haveprotected
visibility. Usually you would
make these private, but we'll need them this way for the purposes of this exercise.
You should have a public
default constructor that sets the first and last name to Unknown
You should have a public
constructor that takes two arguments for the first name and last
name respectively and stores them into the data members mentioned above.
Both of the functions below should be public
This function should return a reference to an std::string
that is const
.
The function should be callable from a const
instance of Student
.
The return value should of course be the data member holding the first name.
This should work exactly the same as FirstName()
but instead return the student's
last name.
This covers overloads and is something of a stretch goal.
Write a new overload of FirstName()
. It should return Student&
(a reference to itself) and take an std::string
which it should use to overwrite
the student's first name.
This should do exactly the same as the above for FirstName()
but instead, set
the student's last name.
Create a comparison operator which returns true
if both the first and last
names are the same. otherwise, return false
.