| 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
Namein header filename.hand source filename.cpp. - An object of type
Nameshould act as if it maintains three pieces of data:- A
stringholding someone’s first name. - A
stringholding someone’s last name. - A
boolindicating the person’s gender; this istruefor female andfalsefor male.
- A
- Class
Nameshould have the following member functions:- A default constructor. This can set the data members however you want.
- A three-parameter constructor that takes two
strings 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 optionalostreamparameter (usecoutif 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
constqualifier 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