Hey guys,
After fixing one of my earlier problems I ran into another one. Basically I'm trying to make an inherited class and add one more parameter to its constructor, but I can't seem to do it properly
Here is the masterclass definition Package
#ifndef PACKAGE_H
#define PACKAGE_H
#include <string>
using std::string;
class Package
{
public:
// constructor initiliazes data members
Package( const string &, const string &, const string &,
const string &, int, const string &, const string &, const string &,
const string &, int, double, double );
void setSenderName( const string & ); // set sender's name
string getSenderName() const; // return sender's name
void setSenderAddress( const string & ); // set sender's address
string getSenderAddress() const; // return sender's address
void setSenderCity( const string & ); // set sender's city
string getSenderCity() const; // return sender's city
void setSenderState( const string & ); // set sender's state
string getSenderState() const; // return sender's state
void setSenderZIP( int ); // set sender's ZIP code
int getSenderZIP() const; // return sender's ZIP code
void setRecipientName( const string & ); // set recipient's name
string getRecipientName() const; // return recipient's name
void setRecipientAddress( const string & ); // set recipient's address
string getRecipientAddress() const; // return recipient's address
void setRecipientCity( const string & ); // set recipient's city
string getRecipientCity() const; // return recipient's city
void setRecipientState( const string & ); // set recipient's state
string getRecipientState() const; // return recipient's state
void setRecipientZIP( int ); // set recipient's ZIP code
int getRecipientZIP() const; // return recipient's ZIP code
void setWeight( double ); // validate and store weight
double getWeight() const; // return weight of package
void setCostPerOunce( double ); // validate and store cost per ounce
double getCostPerOunce() const; // return cost per ounce
double calculateCost() const; // calculate shipping cost for package
private:
// data members to store sender and recipient's address information
string senderName;
string senderAddress;
string senderCity;
string senderState;
int senderZIP;
string recipientName;
string recipientAddress;
string recipientCity;
string recipientState;
int recipientZIP;
double weight; // weight of the package
double costPerOunce; // cost per ounce to ship the package
}; // end class Package
#endif
The functions have all been declared correctly.
Here is the inherited class TwoDayPackage:
class TwoDayPackage: public Package
{
public:
TwoDayPackage( const string &, const string &, const string &,
const string &, int, const string &, const string &, const string &,
const string &, int, double = 0.0, double = 0.0, [I]double = 0.0[/I] );
void setFlatfee ( double );
double getFlatfee () const;
double calculateCost() const;
private:
double flatfee;
};
The red part is the additional data member parameter.
So when I try to define TwoDayPackage's constructor like this:
TwoDayPackage::TwoDayPackage(const string &sn, const string &saddress, const string &scity, const string &sstate, int szipcode, const string &rname, const string &raddress, const string &rcity, const string &rstate, int rzipcode, double wt, double shipCost, double f)
{
setSenderName(sn);
setSenderAddress (saddress);
setSenderCity(scity);
setSenderState(sstate);
setSenderZIP (szipcode);
setRecipientName(rname);
setRecipientAddress(raddress);
setRecipientCity(rcity);
setRecipientState(rstate);
setRecipientZIP(rzipcode);
setWeight(wt);
setCostPerOunce(shipCost);
setFlatfee(f);
}
it gives me the following error
[Error] C:\Users\Flynn\Documents\Cpp\Package.cpp:235: no matching function for call to `Package:: Package ()'
I think I'm doing something wrong when I'm overwriting the default Package constructor with the one I want for TwoDayPackage which contains an additional data member in its parameter and definition.
Anyone know what I'm doing wrong?
Thanks in advance