 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Guybrush Threepwood Guest
|
Posted: Thu Feb 26, 2004 9:09 pm Post subject: what is the difference between these two declarations |
|
|
Hi,
I was always wondering if there is any difference between
void someFunction(int,int)
and
void someFunction(int A, int B)
is there?
|
|
| Back to top |
|
 |
Rolf Magnus Guest
|
Posted: Thu Feb 26, 2004 9:18 pm Post subject: Re: what is the difference between these two declarations |
|
|
Guybrush Threepwood wrote:
| Quote: | Hi,
I was always wondering if there is any difference between
void someFunction(int,int)
and
void someFunction(int A, int B)
is there?
|
No difference.
|
|
| Back to top |
|
 |
Leor Zolman Guest
|
Posted: Thu Feb 26, 2004 9:29 pm Post subject: Re: what is the difference between these two declarations |
|
|
On Thu, 26 Feb 2004 22:18:25 +0100, Rolf Magnus <ramagnus (AT) t-online (DOT) de>
wrote:
| Quote: | Guybrush Threepwood wrote:
Hi,
I was always wondering if there is any difference between
void someFunction(int,int)
and
void someFunction(int A, int B)
is there?
No difference.
|
....assuming they're declarations and the OP simply omitted the semicolons
inadvertently. If they're the first line of function /definitions/,
however, there would certainly be a difference (in the first case, there'd
be no way to access the parameters.)
-leor
Leor Zolman
BD Software
[email]leor (AT) bdsoft (DOT) com[/email]
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software's free STL Error Message
Decryptor at www.bdsoft.com/tools/stlfilt.html
|
|
| Back to top |
|
 |
Mike Wahler Guest
|
Posted: Thu Feb 26, 2004 9:29 pm Post subject: Re: what is the difference between these two declarations |
|
|
"Guybrush Threepwood" <sales (AT) sco (DOT) com> wrote
| Quote: | Hi,
I was always wondering if there is any difference between
void someFunction(int,int)
and
void someFunction(int A, int B)
is there?
|
None from the language perspective. However, using (meaningful)
parameter names in a prototype can aid clarity.
-Mike
|
|
| Back to top |
|
 |
E. Robert Tisdale Guest
|
Posted: Thu Feb 26, 2004 9:31 pm Post subject: Re: what is the difference between these two declarations |
|
|
Guybrush Threepwood wrote:
| Quote: | I was always wondering if there is any difference between
void someFunction(int, int)
and
void someFunction(int A, int B)
is there?
|
The first can only be a declaration.
The second could be the beginning of a definition.
|
|
| Back to top |
|
 |
Joe Gottman Guest
|
Posted: Thu Feb 26, 2004 9:47 pm Post subject: Re: what is the difference between these two declarations |
|
|
"Mike Wahler" <mkwahler (AT) mkwahler (DOT) net> wrote
| Quote: | "Guybrush Threepwood" <sales (AT) sco (DOT) com> wrote in message
news:c1lnb4$3d0$2 (AT) news8 (DOT) svr.pol.co.uk...
Hi,
I was always wondering if there is any difference between
void someFunction(int,int)
and
void someFunction(int A, int B)
is there?
None from the language perspective. However, using (meaningful)
parameter names in a prototype can aid clarity.
|
On the other hand, with some compilers not using parameter names can
suppress "unused parameter" warning messages.
Joe Gottman
|
|
| Back to top |
|
 |
Leor Zolman Guest
|
Posted: Thu Feb 26, 2004 10:27 pm Post subject: Re: what is the difference between these two declarations |
|
|
On Thu, 26 Feb 2004 13:31:24 -0800, "E. Robert Tisdale"
<E.Robert.Tisdale (AT) jpl (DOT) nasa.gov> wrote:
| Quote: | Guybrush Threepwood wrote:
I was always wondering if there is any difference between
void someFunction(int, int)
and
void someFunction(int A, int B)
is there?
The first can only be a declaration.
The second could be the beginning of a definition.
|
Both can be declarations (and that's /all/ they'd be if you added a
semicolon), and both can be the beginning of function definitions. There'd
just be no way to get to the parameters in the first case.
-leor
Leor Zolman
BD Software
[email]leor (AT) bdsoft (DOT) com[/email]
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software's free STL Error Message
Decryptor at www.bdsoft.com/tools/stlfilt.html
|
|
| Back to top |
|
 |
Nick Hounsome Guest
|
Posted: Thu Feb 26, 2004 11:24 pm Post subject: Re: what is the difference between these two declarations |
|
|
"Leor Zolman" <leor (AT) bdsoft (DOT) com> wrote
| Quote: | On Thu, 26 Feb 2004 13:31:24 -0800, "E. Robert Tisdale"
[email]E.Robert.Tisdale (AT) jpl (DOT) nasa.gov[/email]> wrote:
Guybrush Threepwood wrote:
I was always wondering if there is any difference between
void someFunction(int, int)
and
void someFunction(int A, int B)
is there?
The first can only be a declaration.
The second could be the beginning of a definition.
Both can be declarations (and that's /all/ they'd be if you added a
semicolon), and both can be the beginning of function definitions. There'd
just be no way to get to the parameters in the first case.
-leor
|
There's even a common and reasonable use for a declaration and definition
with no
parameter name: operator++(int) - the post increment operator
| Quote: |
Leor Zolman
BD Software
[email]leor (AT) bdsoft (DOT) com[/email]
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software's free STL Error Message
Decryptor at www.bdsoft.com/tools/stlfilt.html
|
|
|
| Back to top |
|
 |
Leor Zolman Guest
|
Posted: Fri Feb 27, 2004 9:46 pm Post subject: Re: what is the difference between these two declarations |
|
|
On Thu, 26 Feb 2004 23:24:19 -0000, "Nick Hounsome"
<nh002 (AT) blueyonder (DOT) co.uk> wrote:
| Quote: |
"Leor Zolman" <leor (AT) bdsoft (DOT) com> wrote in message
news:ress30p63cshtrr96pkrnvni8idl875n14 (AT) 4ax (DOT) com...
On Thu, 26 Feb 2004 13:31:24 -0800, "E. Robert Tisdale"
[email]E.Robert.Tisdale (AT) jpl (DOT) nasa.gov[/email]> wrote:
Guybrush Threepwood wrote:
I was always wondering if there is any difference between
void someFunction(int, int)
and
void someFunction(int A, int B)
is there?
The first can only be a declaration.
The second could be the beginning of a definition.
Both can be declarations (and that's /all/ they'd be if you added a
semicolon), and both can be the beginning of function definitions. There'd
just be no way to get to the parameters in the first case.
-leor
There's even a common and reasonable use for a declaration and definition
with no
parameter name: operator++(int) - the post increment operator
|
Sure. I use the mechanism in at least three different places in each
version of my InitUtil library:
http://www.bdsoft.com/tools/initutil.html
In those cases, template parameters are only mined for their type
information.
-leor
Leor Zolman
BD Software
[email]leor (AT) bdsoft (DOT) com[/email]
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software's free STL Error Message
Decryptor at www.bdsoft.com/tools/stlfilt.html
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|