//Hi i do the delivery company project,this are my members of the base class
//how do i create 2 constructors in base,one for sender and one for recipient?
//I did one for sender ,but visual studio does not allow me to create identical for recipient
//Can some one help to figure it out,please?
#pragma once
#include<string>
using namespace std;
class Package
{
public:
Package();
~Package();
protected:
string senderName;
string senderAddress;
string senderCity;
string senderState;
string senderZipCode;
string recipientName;
string recipientAddress;
string recipientCity;
string recipientState;
string recipientZipCode;
double weight;
double ShippingCost;
public:
virtual void CalculateCost(void) = 0;
virtual void Display(void) = 0;
//setters for sender
void SetName(string name);
void SetSenderAddress(string address);
void SetSenderCity(string city);
void SetSenderState(string state);
void SetSenderZipCode(string zipCode);
//getters for sender
string GetSenderName(void);
string GetSenderAddress(void);
string GetSenderCity(void);
string GetSenderState(void);
string GetSenderZipCode(void);
//setters for recipient
void SetrecipientName(string name);
void SetrecipientAddress(string address);
void SetrecipientCity(string city);
void SetrecipientState(string state);
void SetrecipientZipCode(string zipCode);
//getters for recipient
string GetRecipientName(void);
string GetRecipientAddress(void);
string GetRecipientCity(void);
string GetRecipientState(void);
string GetRecipientZipCode(void);
//constructors
Package(string sName, string sAddress, string sCity, string sState, string sZip);
};
aluhnev
0
Junior Poster in Training
Recommended Answers
Jump to PostI would recommend that you create a support class, call it Person, that encapsulates name, address, city, state, and zipcode. That will simplify the underlying code considerably. IE:
class Person { private: string name; string address; string city; string state; string zipCode; public: Person() {} Person(const string& …
Jump to PostI think that rather begs the question why would you want to create a package that either doesn't have a sender or doesn't have a receiver? Almost by definition a package should have both.
Building on what @rubberman provided you can easily do this just by using the default constructor …
Jump to PostYou probably forgot the definition of Person, or forgot to include the Person.h header file.
All 10 Replies
rubberman
1,355
Nearly a Posting Virtuoso
Featured Poster
ddanbe
commented:
Great recommendation.
+15
aluhnev
0
Junior Poster in Training
aluhnev
0
Junior Poster in Training
Banfa
597
Posting Pro
Featured Poster
aluhnev
0
Junior Poster in Training
aluhnev
0
Junior Poster in Training
Banfa
597
Posting Pro
Featured Poster
aluhnev
0
Junior Poster in Training
Banfa
597
Posting Pro
Featured Poster
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.