![]() |
Commenting out parameter names in function parameter list?
Here's an example of some WTL code;
:
Notice that the parameter names are commented out. I am sure I came across an explanation of why this is a good thing to do but can't for the life of me remember what it was or where I heard it. Anyone know why this is done and is it good practice? WTL code (from codeproject at least) is full of this. |
The prototype only requires the types. One wouldn't want to suggest that you have to use specific names, but the commented names are suggestive of the purpose of the argument. It's exemplar. You should use names (despite the fact that they aren't required) that provide useful commentary in your particular application.
|
I think also if you comment out the parameter name, the compiler won't complain that the parameter is unused. In this example, nothing is used, so they are all commented out. Mind you the compiler should still be complaining about not returning a valid return value.
|
The parameter is used plenty Dark, it's just that the compiler doesn't care about the name of the variable at that point. You can write:
:
LRESULT MainDialog::OnInitDialog(UINT, WPARAM ,LPARAM, BOOL&)And the thing will still run fine. The commented out names just suggest the purpose to the programmer before it looks through all the code. When you do the actual function definition, all the variables will still need names so that you can access them. |
Quote:
|
Quote:
Thanks all for your replies. |
| All times are GMT -5. The time now is 12:17 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC