//why the getters declared twice,public,and than protected at the end of this code?
And how to assign the copy constructor between this 2 classes?
class Person
{
private:
string name;
string address;
string city;
string state;
string zipCode;
public:
Person() {}
Person(const string& aName,
const string& anAddress,
const string& aCity,
const string& aState,
const string& aZipCode) : name(aName),
address(anAddress),
city(aCity),
state(aState),
zipCode(aZipCode) {}
~Person() {}
// Getters
const string& getName() const { return name; }
const string& getAddress() const { return address; }
const string& getCity() const { return city; }
const string& getState() const { return state; }
const string& getZipCode() const { return zipCode; }
// Setters
void setName( const string& aName );
void setAddress( const string& anAddress );
void setCity( const string& aCity );
void setState( const string& aState );
void setZipCode( const string& aZipCode );
};
class Package
{
private:
Person sender;
Person recipient;
public:
Package();
Package( const Person& aSender, const Person& aRecipient)
: sender(aSender), recipient(aRecipient) {}
virtual ~Package();
virtual void CalculateCost(void) = 0;
virtual void Display(void) = 0;
//setters
void setSender(const Person& aPerson);
void setRecipient(const Person& aPerson);
//getters
const Person& getSender() const { return sender; }
const Person& getRecipient() const { return recipient; }
protected:
Person& getSender() { return sender; }
Person& getRecipient() { return recipient; }
};
aluhnev 0 Junior Poster in Training
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.