inheritance ralated

#include<iostream>
using namespace std;
class package{
protected:
double weight,cost_prer_ounce;//how do i ensure that weight and cost_per_ounce //take only positive values
package(){
weight=0; cost_prer_ounce=1.5;
}
double calculatecost(){double a;
cout<<"enter the weigth\n";
cin>>weight;
cin>>weight; a=weight*cost_prer_ounce;
return a;
}
};
class twodaypackage:public package{//how do i add the return value of //calculatecost function in the base class to the calculatecost function of the //derived class.
double flat_fee;
public:
twodaypackage(){
cout<<"enter the fee for a two day package delivery\n";
cin>>flat_fee;
}
double calculatecost(){
flat_fee + =?

cout<<"cost for two day package delivery is "<<flat_fee<<endl;
}


};
flat_fee += Base::calculatecost();
Topic archived. No new replies allowed.