};
template <class burner>
device<burner>::device()
{
int i;
cout<<"Enter :\n The number of burners for that specific type :\n";
cin>>n;
P=(burner*)malloc(n*sizeof(burner));
if (P==NULL) {
cout<<"there is no memory to be allocated! \n";
exit(1);
}
for (i=0;i<n;i++) {
cout<<"The maximum power of the burner:\n";
cin>>P[i];
}
FR=(burner*)malloc(n*sizeof(burner));
if (FR==NULL) {
cout<<"there is no memory to be allocated! \n";
exit(2);
}
for (i=0;i<n;i++) {
cout<<"The fuels required for the maximum power of the burner :\n";
cin>>FR[i];
}
kind_burner=(burner*)malloc(n*sizeof(burner));
if (kind_burner==NULL) {
cout<<"there is no memory to be allocated!\n";
exit(3);
}
for (i=0;i<n;i++) {
kind_burner[i]=P[i]/FR[i];
}
}
class oil_burner
{
protected:
int n,*id_burner;
float *P,*FR,*cost_fuel_per_unit,*cost_burner,*cost_maintenance;
public:
oil_burner();
float b_short();
};
oil_burner::oil_burner()
{
int i;
cout<<"Enter :\n The number of burners for that specific type :\n";
cin>>n;
id_burner=(int*)malloc(n*sizeof(int));
if (id_burner==NULL) {
cout<<"there is no memory to be allocated! \n";
exit(1);
}
for (i=0;i<n;i++) {
cout<<"The identity of the burner :\n";
cin>>id_burner[i];
}
P=(float*)malloc(n*sizeof(float));
if (P==NULL) {
cout<<"there is no memory to be allocated! \n";
exit(2);
}
for (i=0;i<n;i++) {
cout<<"The maximum power of the burner:\n";
cin>>P[i];
}
FR=(float*)malloc(n*sizeof(float));
if (FR==NULL) {
cout<<"there is no memory to be allocated! \n";
exit(3);
}
for (i=0;i<n;i++) {
cout<<"The fuels required for the maximum power of the burner :\n";
cin>>FR[i];
}
cost_fuel_per_unit=(float*)malloc(n*sizeof(float));
if (cost_fuel_per_unit==NULL) {
cout<<"there is no memory to be allocated! \n";
exit(4);
}
for (i=0;i<n;i++) {
cout<<"The cost of fuels per unit :\n";
cin>>cost_fuel_per_unit[i];
}
cost_burner=(float*)malloc(n*sizeof(float));
if (cost_burner==NULL) {
cout<<"there is no memory to be allocated! \n";
exit(5);
}
for (i=0;i<n;i++) {
cout<<"The cost of the burner :\n";
cin>>cost_burner[i];
}
cost_maintenance=(float*)malloc(n*sizeof(float));
if (cost_maintenance==NULL) {
cout<<"there is no memory to be allocated! \n";
exit(6);
}
for (i=0;i<n;i++) {
cout<<"The maintenace cost of the installation :\n";
cin>>cost_maintenance[i];
}
}
template <>
class device<oil_burner>
{
private:
int n;
oil_burner *P,*FR,*kind_burner;
public:
device();
};
device<oil_burner>::device()
{
int i;
cout<<"Enter :\n The number of burners for that specific type :\n";
cin>>n;
P=(oil_burner*)malloc(n*sizeof(oil_burner));
if (P==NULL) {
cout<<"there is no memory to be allocated! \n";
exit(1);
}
for (i=0;i<n;i++) {
cout<<"The maximum power of the burner:\n";
cin>>P[i];
}
}
int main ()
{
int days_operation;
float min_power_burner,cost_burner,cost_maintenance;
cout<<"Enter :\n The minmum power burner of the installation :\n";
cin>>min_power_burner;
cout<<"The available money for purchase burner :\n";
cin>>cost_burner;
cout<<"The money required for the maintenance of the burner :\n";
cin>>cost_maintenance;
cout<<"The days operates the heating during the year :\n";
cin>>days_operation;
device<oil_burner> obj1;