Re: Function prototype vs implementation mismatch in C++
From: jeffc (nobody_at_nowhere.com)
Date: 05/17/04
- Previous message: jeffc: "Re: Pass by ref vs. value"
- In reply to: News: "Function prototype vs implementation mismatch in C++"
- Next in thread: Greg Comeau: "Re: Function prototype vs implementation mismatch in C++"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 17 May 2004 14:55:05 -0400
"News" <NoMail@127.0.0.1> wrote in message
news:cw8qc.353$Id4.120@newsfe6-gui.server.ntli.net...
> class test
> {
> public:
> void display(const int x);
> };
>
> void test::display(int num)
By the way, on a tangent, I found it curious that you named those parms as
you did - "x" in the declaration, and "num" in the implementation. You
don't need a name in the declaration. The only purpose for putting one
there would be to inform the user of the API (header file). Even then, it's
only to save writing the comment. Theoretically, it's consistent with OO
philosophy to *not* name the parameter, since that is an implementation
detail. You could write
void display(const int); // the number to display
to save the comment
void display(const int numToDisplay);
Then the developer is free to use whatever name is most appropriate. In
some cases, it could be that one name is appropriate for the user interface
(to make it easier for callers to understand), and for whatever subtle
reason a slightly different name might be more appropriate. I can't think
of any reason to make the more obscure name to be in the header file though
:-)
- Previous message: jeffc: "Re: Pass by ref vs. value"
- In reply to: News: "Function prototype vs implementation mismatch in C++"
- Next in thread: Greg Comeau: "Re: Function prototype vs implementation mismatch in C++"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|