SlideShare a Scribd company logo
1 of 17
Download to read offline
// PersonData.h
#ifndef PersonData_h
#define PersonData_h
#include
#include
#include
using namespace std;
class PersonData {
protected:
//member variables
string lastName; //holds the users last name
string firstName; //holds the users first name
string address; //holds the users address
string city; //holds the users city
string state; //holds the users state
int zip; //holds the users zip code
int phone; //holds the users phone number
public:
//constructors and destructor
PersonData(); //default constructor
PersonData( string ln , string fn , string addr , string c , string s , int z , int p); // overloaded
constructor
~PersonData(){ /*cout << "The object has been deleted." << endl ;*/ } //destructor
//member functions
//returns the users lastName
string getLastName();
//sets the users lastName
void setLastName( string lastN );
//returns the users firstName
string getFirstName();
//sets the users firstName
void setFirstName( string firstN );
//returns the users address
string getAddress();
//sets the users address
void setAddress( string addr );
//returns the users city
string getCity();
//sets the users city
void setCity( string city );
//returns the users state
string getState();
//sets the users state
void setState( string state );
//returns the users zip
int getZip();
//sets the users zip
void setZip( int zip );
//returns the users phone
int getPhone();
//sets the users phone
void setPhone( int phone );
};
#endif /* PersonData_h */
// PersonData.cpp
#include
#include "PersonData.h"
using namespace std;
//constructors and destructor
PersonData::PersonData(){
//defining arbitrary values for member variables
string lastName = ""; //holds the users last name
string firstName = ""; //holds the users first name
string address = ""; //holds the users address
string city = ""; //holds the users city
string state = ""; //holds the users state
int zip = 0; //holds the users zip code
int phone = 0; //holds the users phone number
}//default constructor
PersonData::PersonData( string strln , string name , string stradd , string liveingcity , string
livingstate , int code , int number){
// user defined values for member variables
string lastName = strln; //holds the users last name
string firstName = name; //holds the users first name
string address = stradd; //holds the users address
string city = liveingcity; //holds the users city
string state = livingstate; //holds the users state
int zip = code; //holds the users zip code
int phone = number; //holds the users phone number
}// overloaded constructor
//member functions
//returns the users lastName
string PersonData::getLastName(){
return lastName;
}
//sets the users lastName
void PersonData::setLastName( string lastN ){
lastName = lastN;
}
//returns the users firstName
string PersonData::getFirstName(){
return firstName;
}
//sets the users firstName
void PersonData::setFirstName( string firstN ){
firstName = firstN;
}
//returns the users address
string PersonData::getAddress(){
return address;
};
//sets the users address
void PersonData::setAddress( string addr ){
address = addr;
}
//returns the users city
string PersonData::getCity(){
return city ;
}
//sets the users city
void PersonData::setCity( string c ){
city = c;
}
//returns the users state
string PersonData::getState(){
return state;
}
//sets the users state
void PersonData::setState( string s ){
state = s;
}
//returns the users zip
int PersonData::getZip(){
return zip;
}
//sets the users zip
void PersonData::setZip( int z ){
zip = z;
}
//returns the users phone
int PersonData::getPhone(){
return phone;
}
//sets the users phone
void PersonData::setPhone( int p ){
phone = p;
}
// CustomerData.h
#ifndef CustomerData_h
#define CustomerData_h
#include
#include "PersonData.h"
class CustomerData : public PersonData {
private:
//member variables
int customerNumber; //holds a unique integer ID for each customer
bool mailingList; //holds a bool indicating whether the customer has opted into the mailing
list
public:
//constructors and destructor
//default constructor
CustomerData(){ customerNumber = 0; mailingList = false; }
//overloaded constructor
CustomerData( int cn , bool ml ){ customerNumber = cn ; mailingList = ml; }
//destructor
~CustomerData(){ /*cout << "The object has been deleted." << endl;*/ }
//member functions
//returns the users customerNumber
int getCustomerNumber();
//sets the users customerNumber
void setCustomerNumber( int ID );
//returns mailingList
bool getMailingList();
//sets mailingList
void setMailingList( bool list );
//ask if the user wishes to join the list
void displayCustomer();
};
#endif /* CustomerData_h */
// CustomerData.cpp
#include "CustomerData.h"
//returns the users customerNumber
int CustomerData::getCustomerNumber(){
return customerNumber;
}
//sets the users customerNumber
void CustomerData::setCustomerNumber( int ID ){
customerNumber = ID;
}
//returns mailingList
bool CustomerData::getMailingList(){
return mailingList;
}
//sets mailingList
void CustomerData::setMailingList( bool list ){
mailingList = list;
}
//asks if the user wishes to join the mailing list
void CustomerData::displayCustomer(){
cout << "Last Name: " << getLastName() << endl;
cout << "First Name: " << getFirstName() << endl;
cout << "Address: " << getAddress() << endl;
cout << "City: " << getCity() << endl;
cout << "State: " << getState() << endl;
cout << "ZIP Code: " << getZip() << endl;
cout << "Customer Number: " << getCustomerNumber() << endl;
cout << "Mailing List? ";
if (getMailingList())
{
cout << "Yes" << endl << endl;
}
else
{
cout << "No" << endl << endl;
}
}
// main.cpp
#include
#include
#include "CustomerData.h"
#include "PersonData.h"
int main()
{
CustomerData c1; //Customer Data objects
CustomerData c2;
cout << "Customer #1" << endl;
cout << "------------" << endl;
c1.setLastName("Smith");
c1.setFirstName("Joan");
c1.setAddress("123 Main Street");
c1.setCity("Smithville");
c1.setState("NC");
c1.setZip(99999);
c1.setPhone(555555);
c1.setCustomerNumber(12345);
c1.setMailingList(1);
c1.displayCustomer();
cout << "Customer #2" << endl;
cout << "------------" << endl;
c2.setLastName("Jones");
c2.setFirstName("Jenny");
c2.setAddress("555 East Street");
c2.setCity("Jonesville");
c2.setState("VA");
c2.setZip(88888);
c2.setPhone(89787887);
c2.setCustomerNumber(77777);
c2.setMailingList(0);
c2.displayCustomer();
return 0;
}
/*
output:
Customer #1
------------
Last Name: Smith
First Name: Joan
Address: 123 Main Street
City: Smithville
State: NC
ZIP Code: 99999
Customer Number: 12345
Mailing List? Yes
Customer #2
------------
Last Name: Jones
First Name: Jenny
Address: 555 East Street
City: Jonesville
State: VA
ZIP Code: 88888
Customer Number: 77777
Mailing List? No
*/
/*
compilation: g++ main.cpp CustomerData.cpp PersonData.cpp
run: ./a.out
*/
Solution
// PersonData.h
#ifndef PersonData_h
#define PersonData_h
#include
#include
#include
using namespace std;
class PersonData {
protected:
//member variables
string lastName; //holds the users last name
string firstName; //holds the users first name
string address; //holds the users address
string city; //holds the users city
string state; //holds the users state
int zip; //holds the users zip code
int phone; //holds the users phone number
public:
//constructors and destructor
PersonData(); //default constructor
PersonData( string ln , string fn , string addr , string c , string s , int z , int p); // overloaded
constructor
~PersonData(){ /*cout << "The object has been deleted." << endl ;*/ } //destructor
//member functions
//returns the users lastName
string getLastName();
//sets the users lastName
void setLastName( string lastN );
//returns the users firstName
string getFirstName();
//sets the users firstName
void setFirstName( string firstN );
//returns the users address
string getAddress();
//sets the users address
void setAddress( string addr );
//returns the users city
string getCity();
//sets the users city
void setCity( string city );
//returns the users state
string getState();
//sets the users state
void setState( string state );
//returns the users zip
int getZip();
//sets the users zip
void setZip( int zip );
//returns the users phone
int getPhone();
//sets the users phone
void setPhone( int phone );
};
#endif /* PersonData_h */
// PersonData.cpp
#include
#include "PersonData.h"
using namespace std;
//constructors and destructor
PersonData::PersonData(){
//defining arbitrary values for member variables
string lastName = ""; //holds the users last name
string firstName = ""; //holds the users first name
string address = ""; //holds the users address
string city = ""; //holds the users city
string state = ""; //holds the users state
int zip = 0; //holds the users zip code
int phone = 0; //holds the users phone number
}//default constructor
PersonData::PersonData( string strln , string name , string stradd , string liveingcity , string
livingstate , int code , int number){
// user defined values for member variables
string lastName = strln; //holds the users last name
string firstName = name; //holds the users first name
string address = stradd; //holds the users address
string city = liveingcity; //holds the users city
string state = livingstate; //holds the users state
int zip = code; //holds the users zip code
int phone = number; //holds the users phone number
}// overloaded constructor
//member functions
//returns the users lastName
string PersonData::getLastName(){
return lastName;
}
//sets the users lastName
void PersonData::setLastName( string lastN ){
lastName = lastN;
}
//returns the users firstName
string PersonData::getFirstName(){
return firstName;
}
//sets the users firstName
void PersonData::setFirstName( string firstN ){
firstName = firstN;
}
//returns the users address
string PersonData::getAddress(){
return address;
};
//sets the users address
void PersonData::setAddress( string addr ){
address = addr;
}
//returns the users city
string PersonData::getCity(){
return city ;
}
//sets the users city
void PersonData::setCity( string c ){
city = c;
}
//returns the users state
string PersonData::getState(){
return state;
}
//sets the users state
void PersonData::setState( string s ){
state = s;
}
//returns the users zip
int PersonData::getZip(){
return zip;
}
//sets the users zip
void PersonData::setZip( int z ){
zip = z;
}
//returns the users phone
int PersonData::getPhone(){
return phone;
}
//sets the users phone
void PersonData::setPhone( int p ){
phone = p;
}
// CustomerData.h
#ifndef CustomerData_h
#define CustomerData_h
#include
#include "PersonData.h"
class CustomerData : public PersonData {
private:
//member variables
int customerNumber; //holds a unique integer ID for each customer
bool mailingList; //holds a bool indicating whether the customer has opted into the mailing
list
public:
//constructors and destructor
//default constructor
CustomerData(){ customerNumber = 0; mailingList = false; }
//overloaded constructor
CustomerData( int cn , bool ml ){ customerNumber = cn ; mailingList = ml; }
//destructor
~CustomerData(){ /*cout << "The object has been deleted." << endl;*/ }
//member functions
//returns the users customerNumber
int getCustomerNumber();
//sets the users customerNumber
void setCustomerNumber( int ID );
//returns mailingList
bool getMailingList();
//sets mailingList
void setMailingList( bool list );
//ask if the user wishes to join the list
void displayCustomer();
};
#endif /* CustomerData_h */
// CustomerData.cpp
#include "CustomerData.h"
//returns the users customerNumber
int CustomerData::getCustomerNumber(){
return customerNumber;
}
//sets the users customerNumber
void CustomerData::setCustomerNumber( int ID ){
customerNumber = ID;
}
//returns mailingList
bool CustomerData::getMailingList(){
return mailingList;
}
//sets mailingList
void CustomerData::setMailingList( bool list ){
mailingList = list;
}
//asks if the user wishes to join the mailing list
void CustomerData::displayCustomer(){
cout << "Last Name: " << getLastName() << endl;
cout << "First Name: " << getFirstName() << endl;
cout << "Address: " << getAddress() << endl;
cout << "City: " << getCity() << endl;
cout << "State: " << getState() << endl;
cout << "ZIP Code: " << getZip() << endl;
cout << "Customer Number: " << getCustomerNumber() << endl;
cout << "Mailing List? ";
if (getMailingList())
{
cout << "Yes" << endl << endl;
}
else
{
cout << "No" << endl << endl;
}
}
// main.cpp
#include
#include
#include "CustomerData.h"
#include "PersonData.h"
int main()
{
CustomerData c1; //Customer Data objects
CustomerData c2;
cout << "Customer #1" << endl;
cout << "------------" << endl;
c1.setLastName("Smith");
c1.setFirstName("Joan");
c1.setAddress("123 Main Street");
c1.setCity("Smithville");
c1.setState("NC");
c1.setZip(99999);
c1.setPhone(555555);
c1.setCustomerNumber(12345);
c1.setMailingList(1);
c1.displayCustomer();
cout << "Customer #2" << endl;
cout << "------------" << endl;
c2.setLastName("Jones");
c2.setFirstName("Jenny");
c2.setAddress("555 East Street");
c2.setCity("Jonesville");
c2.setState("VA");
c2.setZip(88888);
c2.setPhone(89787887);
c2.setCustomerNumber(77777);
c2.setMailingList(0);
c2.displayCustomer();
return 0;
}
/*
output:
Customer #1
------------
Last Name: Smith
First Name: Joan
Address: 123 Main Street
City: Smithville
State: NC
ZIP Code: 99999
Customer Number: 12345
Mailing List? Yes
Customer #2
------------
Last Name: Jones
First Name: Jenny
Address: 555 East Street
City: Jonesville
State: VA
ZIP Code: 88888
Customer Number: 77777
Mailing List? No
*/
/*
compilation: g++ main.cpp CustomerData.cpp PersonData.cpp
run: ./a.out
*/

More Related Content

Similar to PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdf

operating system Ubunut,Linux,Mac filename messageService.cpp.pdf
 operating system Ubunut,Linux,Mac filename messageService.cpp.pdf operating system Ubunut,Linux,Mac filename messageService.cpp.pdf
operating system Ubunut,Linux,Mac filename messageService.cpp.pdfannethafashion
 
maincpp Build and procees a sorted linked list of Patie.pdf
maincpp   Build and procees a sorted linked list of Patie.pdfmaincpp   Build and procees a sorted linked list of Patie.pdf
maincpp Build and procees a sorted linked list of Patie.pdfadityastores21
 
CIS355A_StudentName_CourseProjectCIS355A Week 7 Course Project..docx
CIS355A_StudentName_CourseProjectCIS355A Week 7 Course Project..docxCIS355A_StudentName_CourseProjectCIS355A Week 7 Course Project..docx
CIS355A_StudentName_CourseProjectCIS355A Week 7 Course Project..docxclarebernice
 
prog 5~$AD FOR WHAT TO DO.docxprog 5alerts.txt2009-09-13.docx
prog 5~$AD FOR WHAT TO DO.docxprog 5alerts.txt2009-09-13.docxprog 5~$AD FOR WHAT TO DO.docxprog 5alerts.txt2009-09-13.docx
prog 5~$AD FOR WHAT TO DO.docxprog 5alerts.txt2009-09-13.docxwkyra78
 
#include iostream #include fstream #include cstdlib #.pdf
 #include iostream #include fstream #include cstdlib #.pdf #include iostream #include fstream #include cstdlib #.pdf
#include iostream #include fstream #include cstdlib #.pdfannesmkt
 
Start with the inclusion of libraries#include iostream .docx
 Start with the inclusion of libraries#include iostream .docx Start with the inclusion of libraries#include iostream .docx
Start with the inclusion of libraries#include iostream .docxMARRY7
 
include ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdfinclude ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdfnaslin841216
 
Multithreaded sockets c++11
Multithreaded sockets c++11Multithreaded sockets c++11
Multithreaded sockets c++11Russell Childs
 
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docxRightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docxjoellemurphey
 
Inheritance compiler support
Inheritance compiler supportInheritance compiler support
Inheritance compiler supportSyed Zaid Irshad
 
Program: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 studentsProgram: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 studentsSwarup Boro
 
Q2dayOfYear.cppQ2dayOfYear.cpp  Name   Copyright  .docx
Q2dayOfYear.cppQ2dayOfYear.cpp  Name   Copyright  .docxQ2dayOfYear.cppQ2dayOfYear.cpp  Name   Copyright  .docx
Q2dayOfYear.cppQ2dayOfYear.cpp  Name   Copyright  .docxamrit47
 
運用Closure Compiler 打造高品質的JavaScript
運用Closure Compiler 打造高品質的JavaScript運用Closure Compiler 打造高品質的JavaScript
運用Closure Compiler 打造高品質的JavaScripttaobao.com
 
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic LabsTypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic LabsAlfonso Peletier
 
Having issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdfHaving issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdfrajkumarm401
 
Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01Abdul Samee
 

Similar to PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdf (20)

operating system Ubunut,Linux,Mac filename messageService.cpp.pdf
 operating system Ubunut,Linux,Mac filename messageService.cpp.pdf operating system Ubunut,Linux,Mac filename messageService.cpp.pdf
operating system Ubunut,Linux,Mac filename messageService.cpp.pdf
 
Email Program By Marcelo
Email Program By MarceloEmail Program By Marcelo
Email Program By Marcelo
 
maincpp Build and procees a sorted linked list of Patie.pdf
maincpp   Build and procees a sorted linked list of Patie.pdfmaincpp   Build and procees a sorted linked list of Patie.pdf
maincpp Build and procees a sorted linked list of Patie.pdf
 
Email Program By Marcelo
Email Program By MarceloEmail Program By Marcelo
Email Program By Marcelo
 
Email Program By Marcelo
Email Program By MarceloEmail Program By Marcelo
Email Program By Marcelo
 
CIS355A_StudentName_CourseProjectCIS355A Week 7 Course Project..docx
CIS355A_StudentName_CourseProjectCIS355A Week 7 Course Project..docxCIS355A_StudentName_CourseProjectCIS355A Week 7 Course Project..docx
CIS355A_StudentName_CourseProjectCIS355A Week 7 Course Project..docx
 
prog 5~$AD FOR WHAT TO DO.docxprog 5alerts.txt2009-09-13.docx
prog 5~$AD FOR WHAT TO DO.docxprog 5alerts.txt2009-09-13.docxprog 5~$AD FOR WHAT TO DO.docxprog 5alerts.txt2009-09-13.docx
prog 5~$AD FOR WHAT TO DO.docxprog 5alerts.txt2009-09-13.docx
 
#include iostream #include fstream #include cstdlib #.pdf
 #include iostream #include fstream #include cstdlib #.pdf #include iostream #include fstream #include cstdlib #.pdf
#include iostream #include fstream #include cstdlib #.pdf
 
Start with the inclusion of libraries#include iostream .docx
 Start with the inclusion of libraries#include iostream .docx Start with the inclusion of libraries#include iostream .docx
Start with the inclusion of libraries#include iostream .docx
 
include ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdfinclude ltfunctionalgt include ltiteratorgt inclu.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdf
 
Multithreaded sockets c++11
Multithreaded sockets c++11Multithreaded sockets c++11
Multithreaded sockets c++11
 
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docxRightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
RightTrianglerightTriangle.cppRightTrianglerightTriangle.cpp.docx
 
Inheritance compiler support
Inheritance compiler supportInheritance compiler support
Inheritance compiler support
 
Program: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 studentsProgram: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 students
 
Opp compile
Opp compileOpp compile
Opp compile
 
Q2dayOfYear.cppQ2dayOfYear.cpp  Name   Copyright  .docx
Q2dayOfYear.cppQ2dayOfYear.cpp  Name   Copyright  .docxQ2dayOfYear.cppQ2dayOfYear.cpp  Name   Copyright  .docx
Q2dayOfYear.cppQ2dayOfYear.cpp  Name   Copyright  .docx
 
運用Closure Compiler 打造高品質的JavaScript
運用Closure Compiler 打造高品質的JavaScript運用Closure Compiler 打造高品質的JavaScript
運用Closure Compiler 打造高品質的JavaScript
 
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic LabsTypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
 
Having issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdfHaving issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdf
 
Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01
 

More from annamalaiagencies

volume of NaOh = Volume of HCl ( if both concent.pdf
                     volume of NaOh = Volume of HCl  ( if both concent.pdf                     volume of NaOh = Volume of HCl  ( if both concent.pdf
volume of NaOh = Volume of HCl ( if both concent.pdfannamalaiagencies
 
there is no picture figure of the compound provi.pdf
                     there is no picture figure of the compound provi.pdf                     there is no picture figure of the compound provi.pdf
there is no picture figure of the compound provi.pdfannamalaiagencies
 
nvm i got it. Nickel nitrate will split when goin.pdf
                     nvm i got it. Nickel nitrate will split when goin.pdf                     nvm i got it. Nickel nitrate will split when goin.pdf
nvm i got it. Nickel nitrate will split when goin.pdfannamalaiagencies
 
Which of the following are true when comparing TCPIP to the OSI Ref.pdf
Which of the following are true when comparing TCPIP to the OSI Ref.pdfWhich of the following are true when comparing TCPIP to the OSI Ref.pdf
Which of the following are true when comparing TCPIP to the OSI Ref.pdfannamalaiagencies
 
z = (x - mean)SDz = (50 - 42)10 = 0.8Solutionz = (.pdf
z = (x - mean)SDz = (50 - 42)10 = 0.8Solutionz = (.pdfz = (x - mean)SDz = (50 - 42)10 = 0.8Solutionz = (.pdf
z = (x - mean)SDz = (50 - 42)10 = 0.8Solutionz = (.pdfannamalaiagencies
 
massMass is the property which reflects the quan.pdf
                     massMass is the property which reflects the quan.pdf                     massMass is the property which reflects the quan.pdf
massMass is the property which reflects the quan.pdfannamalaiagencies
 
The lyric solvers in MATLAB® solve these styles of first-order ODEs.pdf
The lyric solvers in MATLAB® solve these styles of first-order ODEs.pdfThe lyric solvers in MATLAB® solve these styles of first-order ODEs.pdf
The lyric solvers in MATLAB® solve these styles of first-order ODEs.pdfannamalaiagencies
 
The most important criteria when a company is considering a supplier.pdf
The most important criteria when a company is considering a supplier.pdfThe most important criteria when a company is considering a supplier.pdf
The most important criteria when a company is considering a supplier.pdfannamalaiagencies
 
The three safety measures that are critical to WLANS are as below..pdf
The three safety measures that are critical to WLANS are as below..pdfThe three safety measures that are critical to WLANS are as below..pdf
The three safety measures that are critical to WLANS are as below..pdfannamalaiagencies
 
The data structures that are associated with system call areThe op.pdf
The data structures that are associated with system call areThe op.pdfThe data structures that are associated with system call areThe op.pdf
The data structures that are associated with system call areThe op.pdfannamalaiagencies
 
it is non linear order is 2 please repost the que.pdf
                     it is non linear order is 2 please repost the que.pdf                     it is non linear order is 2 please repost the que.pdf
it is non linear order is 2 please repost the que.pdfannamalaiagencies
 
Question seems incomplete. Please provide the table.Thanks!!So.pdf
Question seems incomplete. Please provide the table.Thanks!!So.pdfQuestion seems incomplete. Please provide the table.Thanks!!So.pdf
Question seems incomplete. Please provide the table.Thanks!!So.pdfannamalaiagencies
 
Program for prime numbers using Sieveof Eratosthenese Algorithm#i.pdf
Program for prime numbers using Sieveof Eratosthenese Algorithm#i.pdfProgram for prime numbers using Sieveof Eratosthenese Algorithm#i.pdf
Program for prime numbers using Sieveof Eratosthenese Algorithm#i.pdfannamalaiagencies
 
Note according to our guidelines we have to answer for one question.pdf
Note according to our guidelines we have to answer for one question.pdfNote according to our guidelines we have to answer for one question.pdf
Note according to our guidelines we have to answer for one question.pdfannamalaiagencies
 
Live LoadsLive Load vs Dead LoadLive loads are consists of occup.pdf
Live LoadsLive Load vs Dead LoadLive loads are consists of occup.pdfLive LoadsLive Load vs Dead LoadLive loads are consists of occup.pdf
Live LoadsLive Load vs Dead LoadLive loads are consists of occup.pdfannamalaiagencies
 
In our fingers, tendons are present. Tendons are bone-muscle attachm.pdf
In our fingers, tendons are present. Tendons are bone-muscle attachm.pdfIn our fingers, tendons are present. Tendons are bone-muscle attachm.pdf
In our fingers, tendons are present. Tendons are bone-muscle attachm.pdfannamalaiagencies
 
D. orientation note ml decides the orientation .pdf
                     D. orientation  note ml decides the orientation .pdf                     D. orientation  note ml decides the orientation .pdf
D. orientation note ml decides the orientation .pdfannamalaiagencies
 
i) Experiment is carried out to test whether B. cereus or soil bacte.pdf
i) Experiment is carried out to test whether B. cereus or soil bacte.pdfi) Experiment is carried out to test whether B. cereus or soil bacte.pdf
i) Experiment is carried out to test whether B. cereus or soil bacte.pdfannamalaiagencies
 
Big Data in Healthcare Made Simple Where It Stands Today and Where .pdf
Big Data in Healthcare Made Simple Where It Stands Today and Where .pdfBig Data in Healthcare Made Simple Where It Stands Today and Where .pdf
Big Data in Healthcare Made Simple Where It Stands Today and Where .pdfannamalaiagencies
 

More from annamalaiagencies (20)

volume of NaOh = Volume of HCl ( if both concent.pdf
                     volume of NaOh = Volume of HCl  ( if both concent.pdf                     volume of NaOh = Volume of HCl  ( if both concent.pdf
volume of NaOh = Volume of HCl ( if both concent.pdf
 
there is no picture figure of the compound provi.pdf
                     there is no picture figure of the compound provi.pdf                     there is no picture figure of the compound provi.pdf
there is no picture figure of the compound provi.pdf
 
nvm i got it. Nickel nitrate will split when goin.pdf
                     nvm i got it. Nickel nitrate will split when goin.pdf                     nvm i got it. Nickel nitrate will split when goin.pdf
nvm i got it. Nickel nitrate will split when goin.pdf
 
Which of the following are true when comparing TCPIP to the OSI Ref.pdf
Which of the following are true when comparing TCPIP to the OSI Ref.pdfWhich of the following are true when comparing TCPIP to the OSI Ref.pdf
Which of the following are true when comparing TCPIP to the OSI Ref.pdf
 
z = (x - mean)SDz = (50 - 42)10 = 0.8Solutionz = (.pdf
z = (x - mean)SDz = (50 - 42)10 = 0.8Solutionz = (.pdfz = (x - mean)SDz = (50 - 42)10 = 0.8Solutionz = (.pdf
z = (x - mean)SDz = (50 - 42)10 = 0.8Solutionz = (.pdf
 
massMass is the property which reflects the quan.pdf
                     massMass is the property which reflects the quan.pdf                     massMass is the property which reflects the quan.pdf
massMass is the property which reflects the quan.pdf
 
The lyric solvers in MATLAB® solve these styles of first-order ODEs.pdf
The lyric solvers in MATLAB® solve these styles of first-order ODEs.pdfThe lyric solvers in MATLAB® solve these styles of first-order ODEs.pdf
The lyric solvers in MATLAB® solve these styles of first-order ODEs.pdf
 
The most important criteria when a company is considering a supplier.pdf
The most important criteria when a company is considering a supplier.pdfThe most important criteria when a company is considering a supplier.pdf
The most important criteria when a company is considering a supplier.pdf
 
The three safety measures that are critical to WLANS are as below..pdf
The three safety measures that are critical to WLANS are as below..pdfThe three safety measures that are critical to WLANS are as below..pdf
The three safety measures that are critical to WLANS are as below..pdf
 
The data structures that are associated with system call areThe op.pdf
The data structures that are associated with system call areThe op.pdfThe data structures that are associated with system call areThe op.pdf
The data structures that are associated with system call areThe op.pdf
 
it is non linear order is 2 please repost the que.pdf
                     it is non linear order is 2 please repost the que.pdf                     it is non linear order is 2 please repost the que.pdf
it is non linear order is 2 please repost the que.pdf
 
Question seems incomplete. Please provide the table.Thanks!!So.pdf
Question seems incomplete. Please provide the table.Thanks!!So.pdfQuestion seems incomplete. Please provide the table.Thanks!!So.pdf
Question seems incomplete. Please provide the table.Thanks!!So.pdf
 
Program for prime numbers using Sieveof Eratosthenese Algorithm#i.pdf
Program for prime numbers using Sieveof Eratosthenese Algorithm#i.pdfProgram for prime numbers using Sieveof Eratosthenese Algorithm#i.pdf
Program for prime numbers using Sieveof Eratosthenese Algorithm#i.pdf
 
Note according to our guidelines we have to answer for one question.pdf
Note according to our guidelines we have to answer for one question.pdfNote according to our guidelines we have to answer for one question.pdf
Note according to our guidelines we have to answer for one question.pdf
 
Live LoadsLive Load vs Dead LoadLive loads are consists of occup.pdf
Live LoadsLive Load vs Dead LoadLive loads are consists of occup.pdfLive LoadsLive Load vs Dead LoadLive loads are consists of occup.pdf
Live LoadsLive Load vs Dead LoadLive loads are consists of occup.pdf
 
elemination reaction .pdf
                     elemination reaction                             .pdf                     elemination reaction                             .pdf
elemination reaction .pdf
 
In our fingers, tendons are present. Tendons are bone-muscle attachm.pdf
In our fingers, tendons are present. Tendons are bone-muscle attachm.pdfIn our fingers, tendons are present. Tendons are bone-muscle attachm.pdf
In our fingers, tendons are present. Tendons are bone-muscle attachm.pdf
 
D. orientation note ml decides the orientation .pdf
                     D. orientation  note ml decides the orientation .pdf                     D. orientation  note ml decides the orientation .pdf
D. orientation note ml decides the orientation .pdf
 
i) Experiment is carried out to test whether B. cereus or soil bacte.pdf
i) Experiment is carried out to test whether B. cereus or soil bacte.pdfi) Experiment is carried out to test whether B. cereus or soil bacte.pdf
i) Experiment is carried out to test whether B. cereus or soil bacte.pdf
 
Big Data in Healthcare Made Simple Where It Stands Today and Where .pdf
Big Data in Healthcare Made Simple Where It Stands Today and Where .pdfBig Data in Healthcare Made Simple Where It Stands Today and Where .pdf
Big Data in Healthcare Made Simple Where It Stands Today and Where .pdf
 

Recently uploaded

APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 

Recently uploaded (20)

APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 

PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdf

  • 1. // PersonData.h #ifndef PersonData_h #define PersonData_h #include #include #include using namespace std; class PersonData { protected: //member variables string lastName; //holds the users last name string firstName; //holds the users first name string address; //holds the users address string city; //holds the users city string state; //holds the users state int zip; //holds the users zip code int phone; //holds the users phone number public: //constructors and destructor PersonData(); //default constructor PersonData( string ln , string fn , string addr , string c , string s , int z , int p); // overloaded constructor ~PersonData(){ /*cout << "The object has been deleted." << endl ;*/ } //destructor //member functions //returns the users lastName string getLastName(); //sets the users lastName void setLastName( string lastN ); //returns the users firstName string getFirstName(); //sets the users firstName void setFirstName( string firstN );
  • 2. //returns the users address string getAddress(); //sets the users address void setAddress( string addr ); //returns the users city string getCity(); //sets the users city void setCity( string city ); //returns the users state string getState(); //sets the users state void setState( string state ); //returns the users zip int getZip(); //sets the users zip void setZip( int zip ); //returns the users phone int getPhone(); //sets the users phone void setPhone( int phone ); }; #endif /* PersonData_h */ // PersonData.cpp #include #include "PersonData.h" using namespace std; //constructors and destructor PersonData::PersonData(){ //defining arbitrary values for member variables
  • 3. string lastName = ""; //holds the users last name string firstName = ""; //holds the users first name string address = ""; //holds the users address string city = ""; //holds the users city string state = ""; //holds the users state int zip = 0; //holds the users zip code int phone = 0; //holds the users phone number }//default constructor PersonData::PersonData( string strln , string name , string stradd , string liveingcity , string livingstate , int code , int number){ // user defined values for member variables string lastName = strln; //holds the users last name string firstName = name; //holds the users first name string address = stradd; //holds the users address string city = liveingcity; //holds the users city string state = livingstate; //holds the users state int zip = code; //holds the users zip code int phone = number; //holds the users phone number }// overloaded constructor //member functions //returns the users lastName string PersonData::getLastName(){ return lastName; } //sets the users lastName void PersonData::setLastName( string lastN ){ lastName = lastN; } //returns the users firstName string PersonData::getFirstName(){ return firstName; }
  • 4. //sets the users firstName void PersonData::setFirstName( string firstN ){ firstName = firstN; } //returns the users address string PersonData::getAddress(){ return address; }; //sets the users address void PersonData::setAddress( string addr ){ address = addr; } //returns the users city string PersonData::getCity(){ return city ; } //sets the users city void PersonData::setCity( string c ){ city = c; } //returns the users state string PersonData::getState(){ return state; } //sets the users state void PersonData::setState( string s ){ state = s; } //returns the users zip int PersonData::getZip(){ return zip; } //sets the users zip void PersonData::setZip( int z ){ zip = z; }
  • 5. //returns the users phone int PersonData::getPhone(){ return phone; } //sets the users phone void PersonData::setPhone( int p ){ phone = p; } // CustomerData.h #ifndef CustomerData_h #define CustomerData_h #include #include "PersonData.h" class CustomerData : public PersonData { private: //member variables int customerNumber; //holds a unique integer ID for each customer bool mailingList; //holds a bool indicating whether the customer has opted into the mailing list public: //constructors and destructor //default constructor CustomerData(){ customerNumber = 0; mailingList = false; } //overloaded constructor CustomerData( int cn , bool ml ){ customerNumber = cn ; mailingList = ml; } //destructor ~CustomerData(){ /*cout << "The object has been deleted." << endl;*/ } //member functions //returns the users customerNumber int getCustomerNumber(); //sets the users customerNumber
  • 6. void setCustomerNumber( int ID ); //returns mailingList bool getMailingList(); //sets mailingList void setMailingList( bool list ); //ask if the user wishes to join the list void displayCustomer(); }; #endif /* CustomerData_h */ // CustomerData.cpp #include "CustomerData.h" //returns the users customerNumber int CustomerData::getCustomerNumber(){ return customerNumber; } //sets the users customerNumber void CustomerData::setCustomerNumber( int ID ){ customerNumber = ID; } //returns mailingList bool CustomerData::getMailingList(){ return mailingList; } //sets mailingList void CustomerData::setMailingList( bool list ){ mailingList = list; } //asks if the user wishes to join the mailing list void CustomerData::displayCustomer(){ cout << "Last Name: " << getLastName() << endl; cout << "First Name: " << getFirstName() << endl; cout << "Address: " << getAddress() << endl; cout << "City: " << getCity() << endl;
  • 7. cout << "State: " << getState() << endl; cout << "ZIP Code: " << getZip() << endl; cout << "Customer Number: " << getCustomerNumber() << endl; cout << "Mailing List? "; if (getMailingList()) { cout << "Yes" << endl << endl; } else { cout << "No" << endl << endl; } } // main.cpp #include #include #include "CustomerData.h" #include "PersonData.h" int main() { CustomerData c1; //Customer Data objects CustomerData c2; cout << "Customer #1" << endl; cout << "------------" << endl; c1.setLastName("Smith"); c1.setFirstName("Joan"); c1.setAddress("123 Main Street"); c1.setCity("Smithville"); c1.setState("NC"); c1.setZip(99999); c1.setPhone(555555); c1.setCustomerNumber(12345); c1.setMailingList(1); c1.displayCustomer(); cout << "Customer #2" << endl;
  • 8. cout << "------------" << endl; c2.setLastName("Jones"); c2.setFirstName("Jenny"); c2.setAddress("555 East Street"); c2.setCity("Jonesville"); c2.setState("VA"); c2.setZip(88888); c2.setPhone(89787887); c2.setCustomerNumber(77777); c2.setMailingList(0); c2.displayCustomer(); return 0; } /* output: Customer #1 ------------ Last Name: Smith First Name: Joan Address: 123 Main Street City: Smithville State: NC ZIP Code: 99999 Customer Number: 12345 Mailing List? Yes Customer #2 ------------ Last Name: Jones First Name: Jenny Address: 555 East Street City: Jonesville State: VA ZIP Code: 88888 Customer Number: 77777 Mailing List? No
  • 9. */ /* compilation: g++ main.cpp CustomerData.cpp PersonData.cpp run: ./a.out */ Solution // PersonData.h #ifndef PersonData_h #define PersonData_h #include #include #include using namespace std; class PersonData { protected: //member variables string lastName; //holds the users last name string firstName; //holds the users first name string address; //holds the users address string city; //holds the users city string state; //holds the users state int zip; //holds the users zip code int phone; //holds the users phone number public: //constructors and destructor PersonData(); //default constructor PersonData( string ln , string fn , string addr , string c , string s , int z , int p); // overloaded constructor ~PersonData(){ /*cout << "The object has been deleted." << endl ;*/ } //destructor //member functions //returns the users lastName
  • 10. string getLastName(); //sets the users lastName void setLastName( string lastN ); //returns the users firstName string getFirstName(); //sets the users firstName void setFirstName( string firstN ); //returns the users address string getAddress(); //sets the users address void setAddress( string addr ); //returns the users city string getCity(); //sets the users city void setCity( string city ); //returns the users state string getState(); //sets the users state void setState( string state ); //returns the users zip int getZip(); //sets the users zip void setZip( int zip ); //returns the users phone int getPhone(); //sets the users phone void setPhone( int phone ); }; #endif /* PersonData_h */
  • 11. // PersonData.cpp #include #include "PersonData.h" using namespace std; //constructors and destructor PersonData::PersonData(){ //defining arbitrary values for member variables string lastName = ""; //holds the users last name string firstName = ""; //holds the users first name string address = ""; //holds the users address string city = ""; //holds the users city string state = ""; //holds the users state int zip = 0; //holds the users zip code int phone = 0; //holds the users phone number }//default constructor PersonData::PersonData( string strln , string name , string stradd , string liveingcity , string livingstate , int code , int number){ // user defined values for member variables string lastName = strln; //holds the users last name string firstName = name; //holds the users first name string address = stradd; //holds the users address string city = liveingcity; //holds the users city string state = livingstate; //holds the users state int zip = code; //holds the users zip code int phone = number; //holds the users phone number }// overloaded constructor //member functions //returns the users lastName string PersonData::getLastName(){ return lastName; }
  • 12. //sets the users lastName void PersonData::setLastName( string lastN ){ lastName = lastN; } //returns the users firstName string PersonData::getFirstName(){ return firstName; } //sets the users firstName void PersonData::setFirstName( string firstN ){ firstName = firstN; } //returns the users address string PersonData::getAddress(){ return address; }; //sets the users address void PersonData::setAddress( string addr ){ address = addr; } //returns the users city string PersonData::getCity(){ return city ; } //sets the users city void PersonData::setCity( string c ){ city = c; } //returns the users state string PersonData::getState(){ return state; } //sets the users state void PersonData::setState( string s ){ state = s; }
  • 13. //returns the users zip int PersonData::getZip(){ return zip; } //sets the users zip void PersonData::setZip( int z ){ zip = z; } //returns the users phone int PersonData::getPhone(){ return phone; } //sets the users phone void PersonData::setPhone( int p ){ phone = p; } // CustomerData.h #ifndef CustomerData_h #define CustomerData_h #include #include "PersonData.h" class CustomerData : public PersonData { private: //member variables int customerNumber; //holds a unique integer ID for each customer bool mailingList; //holds a bool indicating whether the customer has opted into the mailing list public: //constructors and destructor //default constructor CustomerData(){ customerNumber = 0; mailingList = false; } //overloaded constructor CustomerData( int cn , bool ml ){ customerNumber = cn ; mailingList = ml; } //destructor
  • 14. ~CustomerData(){ /*cout << "The object has been deleted." << endl;*/ } //member functions //returns the users customerNumber int getCustomerNumber(); //sets the users customerNumber void setCustomerNumber( int ID ); //returns mailingList bool getMailingList(); //sets mailingList void setMailingList( bool list ); //ask if the user wishes to join the list void displayCustomer(); }; #endif /* CustomerData_h */ // CustomerData.cpp #include "CustomerData.h" //returns the users customerNumber int CustomerData::getCustomerNumber(){ return customerNumber; } //sets the users customerNumber void CustomerData::setCustomerNumber( int ID ){ customerNumber = ID; } //returns mailingList bool CustomerData::getMailingList(){ return mailingList; } //sets mailingList void CustomerData::setMailingList( bool list ){ mailingList = list;
  • 15. } //asks if the user wishes to join the mailing list void CustomerData::displayCustomer(){ cout << "Last Name: " << getLastName() << endl; cout << "First Name: " << getFirstName() << endl; cout << "Address: " << getAddress() << endl; cout << "City: " << getCity() << endl; cout << "State: " << getState() << endl; cout << "ZIP Code: " << getZip() << endl; cout << "Customer Number: " << getCustomerNumber() << endl; cout << "Mailing List? "; if (getMailingList()) { cout << "Yes" << endl << endl; } else { cout << "No" << endl << endl; } } // main.cpp #include #include #include "CustomerData.h" #include "PersonData.h" int main() { CustomerData c1; //Customer Data objects CustomerData c2; cout << "Customer #1" << endl; cout << "------------" << endl; c1.setLastName("Smith"); c1.setFirstName("Joan"); c1.setAddress("123 Main Street");
  • 16. c1.setCity("Smithville"); c1.setState("NC"); c1.setZip(99999); c1.setPhone(555555); c1.setCustomerNumber(12345); c1.setMailingList(1); c1.displayCustomer(); cout << "Customer #2" << endl; cout << "------------" << endl; c2.setLastName("Jones"); c2.setFirstName("Jenny"); c2.setAddress("555 East Street"); c2.setCity("Jonesville"); c2.setState("VA"); c2.setZip(88888); c2.setPhone(89787887); c2.setCustomerNumber(77777); c2.setMailingList(0); c2.displayCustomer(); return 0; } /* output: Customer #1 ------------ Last Name: Smith First Name: Joan Address: 123 Main Street City: Smithville State: NC ZIP Code: 99999 Customer Number: 12345 Mailing List? Yes Customer #2 ------------
  • 17. Last Name: Jones First Name: Jenny Address: 555 East Street City: Jonesville State: VA ZIP Code: 88888 Customer Number: 77777 Mailing List? No */ /* compilation: g++ main.cpp CustomerData.cpp PersonData.cpp run: ./a.out */