1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
#include <cstring>
#include<iostream>
using namespace std;
class personType
{
public:
void print() const;
//Function to output the first name and last name
//in the form firstName lastName
void setName(string first, string middle, string last);
//Function to set firstName and lastName according to
//the parameters
//Postcondition: firstName = first; lastName = last
string getName(string first, string middle, string last);
//Function to return firstName and lastName via the
//parameters
//Postcondition: first = firstName; last = lastName
string getFirst(string first) const;
string getLast(string last) const;
personType(string first = "", string middle = "", string last = "");
//Constructor
//Set firstName and lastName according to the parameters
//The default values of the parameters are empty strings
//Postcondition: firstName = first; lastName = last
private:
string firstName; //stores the first name
string lastName; //stores the last name
string middleName;
};
//#include <string>
//using namespace std;
//class personType
//{
//public:
// void print() const;
//Function to output the first name and last name
//in the form firstName lastName
void setName(string& first, string& middle, string& last);
//Function to set firstName and lastName according to
//the parameters
//Postcondition: firstName = first; lastName = last
void setLast(string last);
void setFirst(string first);
void setMiddleName(string middle);
string getName(string& first, string& middle, string& last);
//Function to return firstName and lastName via the
//parameters
//Postcondition: first = firstName; last = lastName
// personType(string first = "", string middle = "", string last = "");
//Constructor
//Set firstName and lastName according to the parameters
//The default values of the parameters are empty strings
//Postcondition: firstName = first; lastName = last
//private:
string firstName; //stores the first name
string lastName; //stores the last name
string middleName;
//};
//#include <iostream>
//#include "person.h"
//using namespace std;
void personType::print() const
{
cout<<firstName<<" "<<lastName;
}
void personType::setName(string first, string middle, string last)
{
firstName = first;
middleName = middle;
//void personType::setMiddle(string middle) const
//{
// middleName = middle;
}
string personType::getName(string first, string middle, string last)
{
//first = firstName;
//middle = middleName;
//last = lastName;
return firstName , middleName, lastName;
}
string personType::getFirst(string first) const
{
//first = firstName;
return firstName;
}
string personType::getLast(string last) const
{
// last = lastName;
return lastName;
}
//constructor
personType::personType(string first, string middle, string last)
{
firstName = first;
middleName = middle;
lastName = last;
}
|