what is the difference between these two declarations

  • Thread starter Guybrush Threepwood
  • Start date
G

Guybrush Threepwood

Hi,
I was always wondering if there is any difference between

void someFunction(int,int)

and

void someFunction(int A, int B)

is there?
 
R

Rolf Magnus

Guybrush said:
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.
 
L

Leor Zolman

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
(e-mail address removed)
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
 
M

Mike Wahler

Guybrush Threepwood said:
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
 
E

E. Robert Tisdale

Guybrush said:
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.
 
J

Joe Gottman

Mike Wahler said:
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
 
L

Leor Zolman

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
(e-mail address removed)
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
 
N

Nick Hounsome

Leor Zolman said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top