Hi,
Yes, your last code snippet was what I had in mind.
With the switch cases, I would like see them contain a function call and nothing else. I know that seems to be a pain, but it really does tidy up the code :+)
Another thing about switches, one can set up an
enum
which holds all the options for the switch. Then turn on a compiler warning for when you don't supply a case for each item in the switch.
More variable names to fix up: is
cnt
contents or count, or something else ?
results
is vague. Why is this variable returned at the end of the function? Doesn't it only apply to the E case ?
readToRentals
if that writes to a file, shouldn't it be
writeToRentalsFile
?
One other very small thing: If you format your code editor to replace tabs with spaces, it will display better when you post it here. This site expands tabs to the full 8 spaces, thus showing much more indenting than what was probably in the original.
Also, from a style POV, place your comments before the line the apply to, not at the end, that way I don't have to scroll right all the time.
Here is a web site with c++ best practices, and it contains entries relating to lots of different style guides. Note that the Google style guide is considered rather bad, the JSF Air Vehicle one is allegedly quite good. Some of the others might be good too, I haven't looked at all of them. One can Google a particular style guide, if they want to read the whole document.