The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 399 Weeks Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Assignment 4B: Complete either question 1 or question 2 below.
1. Design a class of type family and define an object from this class.
Include in the class:
private members of strings for husband, wife, son, daughter1, daughter2, and a pointer to family. (Hint regarding the private pointer to family: All you are doing is making a pointer to a class family. By making it private you are deciding that you cannot change the class.)
public void function without arguments called initialize.
void friend function called output with a pointer to family as an argument.
Declare a void function prototype (that will be used for output) for output. Have the output function output on the screen husband is xxxx, wife is xxxx, son is xxxx, daughter1 is xxxx, and daughter2 is xxxx on separate lines. (The xxxx are the respective names used in initialize below.)
Declare a family type object called Simpson.
Include all of the above in a function that uses the public function initialize in Simpson to initialize the pointer to the address of Simpson, and initializes husband as "Donald Simpson," wife as "Shirley Simpson," son as "Horatio Simpson," daughter1 as "Harriet Simpson," and daughter2 as "Hillary Simpson." Also
include in the public function family:
initialize the output function.
Run the program. Explain in a comment at the top of your program why the program would not work as is if the output
function was private and not a friend.
2. Create a person class to represent a person. (You may call the class
personType.) To simplify things, have the class have 2 variable members for the personA????1s first and last name. Include 2 constructors. One should be a default constructor and the other should be one with parameters. Include respective functions for:
setting the name,
getting the name, and
printing the name on the screen.
Have your main program call these functions to demonstrate how they work.
Explain in a comment at the top of your program how you can replace both constructors with one constructor by using a single constructor with
default parameters.
Hel-----------lo -----------Sir-----------/Ma-----------dam----------- Â----------- Th-----------ank----------- Yo-----------u f-----------or -----------usi-----------ng -----------our----------- we-----------bsi-----------te -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill-----------