what is the difference between these two declarations

Discussion in 'C++' started by Guybrush Threepwood, Feb 26, 2004.

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

    void someFunction(int,int)

    and

    void someFunction(int A, int B)

    is there?
     
    Guybrush Threepwood, Feb 26, 2004
    #1
    1. Advertisements

  2. Guybrush Threepwood

    Rolf Magnus Guest

    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.
     
    Rolf Magnus, Feb 26, 2004
    #2
    1. Advertisements

  3. Guybrush Threepwood

    Leor Zolman Guest

    On Thu, 26 Feb 2004 22:18:25 +0100, Rolf Magnus <>
    wrote:

    >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

    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
     
    Leor Zolman, Feb 26, 2004
    #3
  4. Guybrush Threepwood

    Mike Wahler Guest

    "Guybrush Threepwood" <> wrote in message
    news:c1lnb4$3d0$...
    > 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
     
    Mike Wahler, Feb 26, 2004
    #4
  5. 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.
     
    E. Robert Tisdale, Feb 26, 2004
    #5
  6. Guybrush Threepwood

    Joe Gottman Guest

    "Mike Wahler" <> wrote in message
    news:8zt%b.9526$...
    > "Guybrush Threepwood" <> wrote in message
    > news:c1lnb4$3d0$...
    > > 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
     
    Joe Gottman, Feb 26, 2004
    #6
  7. Guybrush Threepwood

    Leor Zolman Guest

    On Thu, 26 Feb 2004 13:31:24 -0800, "E. Robert Tisdale"
    <> 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


    Leor Zolman
    BD Software

    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
     
    Leor Zolman, Feb 26, 2004
    #7
  8. "Leor Zolman" <> wrote in message
    news:...
    > On Thu, 26 Feb 2004 13:31:24 -0800, "E. Robert Tisdale"
    > <> 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

    >
    > Leor Zolman
    > BD Software
    >
    > 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
     
    Nick Hounsome, Feb 26, 2004
    #8
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rach
    Replies:
    2
    Views:
    543
    Andy Fish
    Jun 9, 2004
  2. JohnJSal
    Replies:
    13
    Views:
    616
    John Salerno
    Nov 4, 2006
  3. oo@@oo
    Replies:
    1
    Views:
    359
    Hallvard B Furuseth
    Aug 4, 2006
  4. Manoj
    Replies:
    4
    Views:
    558
    Tomasz Krol
    May 10, 2010
  5. Just Another Victim of the Ambient Morality

    What's the difference between these two block passing strategies?

    Just Another Victim of the Ambient Morality, Jul 20, 2006, in forum: Ruby
    Replies:
    1
    Views:
    154
    Erik Veenstra
    Jul 20, 2006
  6. Mr. Bill
    Replies:
    2
    Views:
    188
    Mr. Bill
    Jan 17, 2011
  7. Replies:
    7
    Views:
    231
    Chris Angelico
    Jan 8, 2013
  8. Yves S. Garret
    Replies:
    15
    Views:
    205
    alex23
    Mar 19, 2013
Loading...