Hello
I've recently noticed that some of you define functions (prototypes) this way:
instead ofCode:void some_function(int, int, int);
Which way is better?Code:void some_function(int a, int b, int c);
Hello
I've recently noticed that some of you define functions (prototypes) this way:
instead ofCode:void some_function(int, int, int);
Which way is better?Code:void some_function(int a, int b, int c);
It depends. In most cases I would say the second one would be better assuming you provided descriptive variable names. That's because it helps to document to the user of the function what the parameters are supposed to mean.
The only case where it might be better to use the first method is for private implementation functions in a class. The implementation of those doesn't need to be known by the user of the class, so it may make sense to hide their meanings.
>Which way is better?
The only time the first option is better, is when you have unused parameters. This can suppress warnings about not using the parameter, and otherwise it's best to name your parameters so that the code documents itself.
My best code is written with the delete key.
>But don't count on it.
I was assuming a conscientious programmer writing good code. Give me a set of style guidelines and I can follow them to the letter, but still produce an unintelligible mess. If you take into account bad programmers, it's impossible to guarantee readable code and we should all take up burger flipping.
My best code is written with the delete key.