I just started learning this C++ language. (I dont have any previous programming experience) Most forums the I've search says this language is unfriendly for beginners in programming, I havent tried learning other language yet thus I cant tell if its true. Anyways, My first program (posted below) is a simple calculator in cmd.
I know that a good program is somewhat simple and neat, so I am welcoming any suggestions and comments for the improvement of this program.
main does not return a void. In the past C functions defaulted to int. so programmers could write main(void) but main void returned int by default just like any other C function with a type return not expressed.
This is not a real criticism, it is just that you should use a new compiler that accepts modern C++.
If you are using goto, it is a good idea for error handling like:
1 2 3 4 5 6 7 8 9 10 11
int function()
{
// some error here
goto error;
// ...
error:
// error handling code here
}
In this way you won't write code that it is hard to mantain. Once I had to fix a 1500 lines function with so many gotos and the only way to solve it was to add a new goto. I know it is ugly, but sometimes it is what you have to do.