Example 10-10 defined a class personType to store the name of a person. The member functions that we included merely print the name and set the name of a person. Redefine the class personType so that, in addition to what the existing class does, you can: Set the first name only. Set the last name only. Store and set the middle name. Check whether a given first name is the same as the first name of this person. Check whether a given last name is the same as the last name of this person.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Example 10-10 defined a class personType to store the name of a person. The member functions that we included merely print the name and set the name of a person. Redefine the class personType so that, in addition to what the existing class does, you can:
- Set the first name only.
- Set the last name only.
- Store and set the middle name.
- Check whether a given first name is the same as the first name of this person.
- Check whether a given last name is the same as the last name of this person.
![O (829) K
O Home
O Merritt
C-25_T
O Prograr : Min x
O PHYS 4
O cis25 la
O cis25 la
E Untitlec
E Untitlec
ь Му Que
T Subscr
O (Solved
b Verify E
M Inbox (
G Google
+
ng.cengage.com/static/nb/ui/evo/index.html?deploymentld=5781122055515575690743039334&elSBN=9781337274715&snapshotld%=1982158&id=934535649&takeld=D002990dd-3047-4db4-a2. *
WILLIYAM v
CENGAGE MINDTAP
Q Search this course
A My Home
Programming Exercise 10-11
+
| Instructions
Courses
main.cpp
personType.h
personTypelmp.cpp
>- Terminal
1 #include "personType.h"
personTypelmp.cpp
Enter first name:
O Catalog and Study Tools
2 #include <string>
• Set the first name only.
3 #include <iostream>
A-Z
Partner Offers
Lll
• Set the last name only.
4
EE Rental Options
5 using namespace std;
• Store and set the middle name.
College Success Tips
• Check whether a given first name is
7 void PersonType::print() const
8 {
the same as the first name of this
Career Success Tips
9
cout << firstName << " " << middleName << " " <<
person.
lastName;
RECOMMENDED FOR YOU
10 }
• Check whether a given last name is
11
the same as the last name of this
12 void PersonType::setName(string first, string last)
13 {
person.
14
firstName = first;
15
lastName = last;
Check In! Sleep Self-
Write the definitions of the member
16 }
Assessment Take the quiz!]
functions to implement the operations
for this class . Also, write a program to
17
18 void PersonType::setFirstName(string f)
Help
test various operations on this class .
19 {
20
firstName = f;
Give Feedback
21 }
Grading
22
23 void PersonType: :setLastName(string 1)
When you have completed your
24 {
program, click the Submit button to
lastName = 1;
25
26 1
record your score.
6 V i 3:25](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ffea7db84-1c24-4b74-999d-45b7b72031d9%2F99b96898-9f21-4d7a-9d66-bddbc9998021%2F95dnf9e_processed.png&w=3840&q=75)

Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images









