CS 202 Fall 2013 > In-Class Challenge for Tuesday, September 17, 2013 |
CS 202 Fall 2013
In-Class Challenge for Tuesday, September 17, 2013
Write a C++ class Name
as follows.
A driver program is written for you:
test_name.cpp
.
- Implement class
Name
in header filename.h
and source filename.cpp
. - An object of type
Name
should act as if it maintains three pieces of data:- A
string
holding someone’s first name. - A
string
holding someone’s last name. - A
bool
indicating the person’s gender; this istrue
for female andfalse
for male.
- A
- Class
Name
should have the following member functions:- A default constructor. This can set the data members however you want.
- A three-parameter constructor that takes two
string
s and abool
. It sets the three pieces of data accordingly. - Get and set functions for the three pieces of data,
written as usual, and named
getFname
,setFname
,getLname
,setLname
,getFemale
,setFemale
. - Function
printFull
. This should take an optionalostream
parameter (usecout
if the parameter is not given). It should print to the give stream the person’s full name with title: “Mr.
” or “Ms.
”, as appropriate, a blank, the first name, a blank, and the last name. No newline should be printed.
- The class should be implemented according to standard conventions regarding header & source file separation, etc.
- The
const
qualifier should be used correctly. - Your package should compile with the test program
test_name.cpp
.
CS 202 Fall 2013: In-Class Challenge for Tuesday, September 17, 2013 /
Updated: 17 Sep 2013 /
Glenn G. Chappell