I am having problems returning a struct.
I created a function currentPeriodCharges that would perform some calculations and return results for their use in another function.
one of the errors include: cannot overload functions distinguished by return type alone
any thoughts?
here is the struct:
typedef struct{
float cpCharges[3];
int cUsage[2];
}mystruct;
here is the function:
mystruct currentPeriodCharges (char a,int b,float c){
mystruct retVal;
int c=100;
if(a=='C'||a=='c'){
retVal.cpCharges[2]=b*rate[1];
retVal.cUsage[0]=0;
retVal.cUsage[1]=0;
retVal.cpCharges[0]=0;
retVal.cpCharges[1]=0;
return retVal;
}
else{
if(a=='R'||a=='r'){
if(b<100){
retVal.cpCharges[2]=b*rate[0];
retVal.cUsage[0]=0;
retVal.cUsage[1]=0;
retVal.cpCharges[0]=0;
retVal.cpCharges[1]=0;
return retVal;
}
else{
if(b>100){
retVal.cUsage[0]=c;
retVal.cUsage[1]=b-retVal.cUsage[0];
retVal.cpCharges[0]=retVal.cUsage[0]*rate[0];
retVal.cpCharges[1]=retVal.cUsage[1]*rate[1];
return retVal;
}
}
}
}
};