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. Advertising

  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. Advertising

  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. Advertising

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:
    437
    Andy Fish
    Jun 9, 2004
  2. JohnJSal
    Replies:
    13
    Views:
    438
    John Salerno
    Nov 4, 2006
  3. oo@@oo
    Replies:
    1
    Views:
    298
    Hallvard B Furuseth
    Aug 4, 2006
  4. Vasileios Zografos

    Any difference in these array declarations

    Vasileios Zografos, Jan 4, 2006, in forum: C++
    Replies:
    18
    Views:
    531
    Frinos
    Jan 5, 2006
  5. Manoj
    Replies:
    4
    Views:
    458
    Tomasz Krol
    May 10, 2010
Loading...

Share This Page