Looking for some feedback...
Hey all,
I've just finished my horsepower calculator and am looking for input. Since everyone I know who knows C/C++ doesn't check their emails for a week or so, I thought this was the most efficient route for getting feedback. The source is attached and needs to be compiled (It works in both MSVC++ .NET and DevCPP 4, so it should compile for most other compilers).
It works on the premise that the user is finding the output at the flywheel and that they are finding both the horsepower and torque (foot-pounds) at a specific RPM output (meaning that the numbers won't match up exactly to factory-rated specs because normally the torque peak is at a lesser RPM than the HP peak is). I'm thinking about doing more calcs for different engine dynamics based on what I get here, so please don't hesitate to give your input. :)
oops, forgot the attachment
oops, I forgot to attach the source... (:eek: ) here, it should work now
A little problem... tell me if I'm doing it right
I've split the menu and the actual action functions, but I encountered a warning - the app still compiled correctly - it's just that warnings annoy me and the fact that the code won't compile correctly on some other compilers leaves that irking feeling at the back of my mind. Anyway, I've narrowed it down to one main function, being the action() or switchmain() as I've labelled it. The error says
Code:
warning C4715: 'switchmain' : not all control paths return a value
Now, I'm thinking that since it has a switch scenario inside the function returning a value (case 0 : return 0) and that anything outside the case scenario is just being left to void(). Since I can't just go and label it void switchmain() because the function itsself is returning a 0 in one part of it, can't I just place a return true; outside the case scenario to remedy that, just as long as I keep the function initiator to something like short int/int switchmain()?
Here's the code:
Code:
short int switchmain(int choice)
{
switch (choice)
{
case 1 : hp_rpm();
break;
case 2 : tq_rpm();
break;
case 3 : hp_tq();
break;
case 4 : ver_info();
break;
case 0 :
cout<<"Please wait, halting program..."<<endl<<endl;
wait();
return 0;;
break;
default:
cout<<"Error, bad input, quitting"<<endl<<endl;
}
return true;
}
I just want to know if I'm doing this right