Mar 25, 2019 at 2:53am UTC
//Person.h
#include "Person.h"
#include <iostream>
#include <string>
using namespace std;
Person::Person()
{
id=0;
name=" ";
address=" ";
}
void Person::setPerson(int id1,string name1,string address1)
{
id=id1;
name=name1;
address=address1;
}
int Person::getId()
{
return id;
}
//void Person::setId(int pid)
//{
// pid=id;
//}
string Person::getName()
{
return name;
}
//void Person::setName(string sn)
//{
// sn=name;
//}
string Person::getAddress()
{
return address;
}
//void Person::setAddress(string add)
//{
// add=address;
//}
void Person::printPerson()
{
cout<<"The ID of the person is "<<id<<endl;
cout<<"The name of the person is "<<name<<endl;
cout<<"The address of the person is "<<address<<endl;
}
Person::~Person()
{
}
Person.cpp
#ifndef PERSON_H
#define PERSON_H
#include <iostream>
#include <string>
using namespace std;
class Person
{
public:
Person();
void setPerson(int,string,string);
~Person();
int getId();
//void setId(int);
string getName();
// void setName(string);
string getAddress();
//void setAddress(string);
void printPerson();
protected:
int id;
string name;
string address;
};
#endif // PERSON_H
//Passenger.h
#ifndef PASSENGER_H
#define PASSENGER_H
#include "Person.h"
#include <iostream>
#include <string>
class Passenger : public Person
{
public:
~Passenger();
Passenger(int=0,string="",string="",string="");
//void setPassenger(string);
string getFrequentFlyerPlan();
//void setFrequentFlyerPlan(string);
void printPerson();
private:
string frequentflyerplan;
};
#endif // PASSENGER_H
//Passenger.cpp file
#include "Passenger.h"
#include "Person.h"
#include <iostream>
#include <string>
using namespace std;
//Passenger::Passenger()
//{
// frequentflyerplan=" ";
//}
Passenger::Passenger(int id1,string name1,string address1,string FFP1):Person(id1,name1,address1)
{
frequentflyerplan=FFP1;
}
string Passenger::getFrequentFlyerPlan()
{
return frequentflyerplan;
}
void Passenger::printPerson()
{
cout<<"What is your frequent flyer plan? "<<frequentflyerplan<<endl;
Person::printPerson();
}
Passenger::~Passenger()
{
}
Last edited on Mar 25, 2019 at 3:15am UTC