what is the difference between these two declarations

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guybrush Threepwood

    what is the difference between these two declarations

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

    void someFunction(in t,int)

    and

    void someFunction(in t A, int B)

    is there?
  • Rolf Magnus

    #2
    Re: what is the difference between these two declarations

    Guybrush Threepwood wrote:
    [color=blue]
    > Hi,
    > I was always wondering if there is any difference between
    >
    > void someFunction(in t,int)
    >
    > and
    >
    > void someFunction(in t A, int B)
    >
    > is there?[/color]

    No difference.

    Comment

    • Leor Zolman

      #3
      Re: what is the difference between these two declarations

      On Thu, 26 Feb 2004 22:18:25 +0100, Rolf Magnus <ramagnus@t-online.de>
      wrote:
      [color=blue]
      >Guybrush Threepwood wrote:
      >[color=green]
      >> Hi,
      >> I was always wondering if there is any difference between
      >>
      >> void someFunction(in t,int)
      >>
      >> and
      >>
      >> void someFunction(in t A, int B)
      >>
      >> is there?[/color]
      >
      >No difference.[/color]

      ....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
      leor@bdsoft.com
      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

      Comment

      • Mike Wahler

        #4
        Re: what is the difference between these two declarations

        "Guybrush Threepwood" <sales@sco.co m> wrote in message
        news:c1lnb4$3d0 $2@news8.svr.po l.co.uk...[color=blue]
        > Hi,
        > I was always wondering if there is any difference between
        >
        > void someFunction(in t,int)
        >
        > and
        >
        > void someFunction(in t A, int B)
        >
        > is there?[/color]

        None from the language perspective. However, using (meaningful)
        parameter names in a prototype can aid clarity.

        -Mike


        Comment

        • Joe Gottman

          #5
          Re: what is the difference between these two declarations


          "Mike Wahler" <mkwahler@mkwah ler.net> wrote in message
          news:8zt%b.9526 $yZ1.6597@newsr ead2.news.pas.e arthlink.net...[color=blue]
          > "Guybrush Threepwood" <sales@sco.co m> wrote in message
          > news:c1lnb4$3d0 $2@news8.svr.po l.co.uk...[color=green]
          > > Hi,
          > > I was always wondering if there is any difference between
          > >
          > > void someFunction(in t,int)
          > >
          > > and
          > >
          > > void someFunction(in t A, int B)
          > >
          > > is there?[/color]
          >
          > None from the language perspective. However, using (meaningful)
          > parameter names in a prototype can aid clarity.
          >[/color]

          On the other hand, with some compilers not using parameter names can
          suppress "unused parameter" warning messages.

          Joe Gottman


          Comment

          • E. Robert Tisdale

            #6
            Re: what is the difference between these two declarations

            Guybrush Threepwood wrote:
            [color=blue]
            > I was always wondering if there is any difference between
            >
            > void someFunction(in t, int)
            >
            > and
            >
            > void someFunction(in t A, int B)
            >
            > is there?[/color]

            The first can only be a declaration.
            The second could be the beginning of a definition.

            Comment

            • Leor Zolman

              #7
              Re: what is the difference between these two declarations

              On Thu, 26 Feb 2004 13:31:24 -0800, "E. Robert Tisdale"
              <E.Robert.Tisda le@jpl.nasa.gov > wrote:
              [color=blue]
              >Guybrush Threepwood wrote:
              >[color=green]
              >> I was always wondering if there is any difference between
              >>
              >> void someFunction(in t, int)
              >>
              >> and
              >>
              >> void someFunction(in t A, int B)
              >>
              >> is there?[/color]
              >
              >The first can only be a declaration.
              >The second could be the beginning of a definition.[/color]

              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
              leor@bdsoft.com
              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

              Comment

              • Nick Hounsome

                #8
                Re: what is the difference between these two declarations


                "Leor Zolman" <leor@bdsoft.co m> wrote in message
                news:ress30p63c shtrr96pkrnvni8 idl875n14@4ax.c om...[color=blue]
                > On Thu, 26 Feb 2004 13:31:24 -0800, "E. Robert Tisdale"
                > <E.Robert.Tisda le@jpl.nasa.gov > wrote:
                >[color=green]
                > >Guybrush Threepwood wrote:
                > >[color=darkred]
                > >> I was always wondering if there is any difference between
                > >>
                > >> void someFunction(in t, int)
                > >>
                > >> and
                > >>
                > >> void someFunction(in t A, int B)
                > >>
                > >> is there?[/color]
                > >
                > >The first can only be a declaration.
                > >The second could be the beginning of a definition.[/color]
                >
                > 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
                >[/color]

                There's even a common and reasonable use for a declaration and definition
                with no
                parameter name: operator++(int) - the post increment operator
                [color=blue]
                >
                > Leor Zolman
                > BD Software
                > leor@bdsoft.com
                > 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[/color]


                Comment

                • Leor Zolman

                  #9
                  Re: what is the difference between these two declarations

                  On Thu, 26 Feb 2004 23:24:19 -0000, "Nick Hounsome"
                  <nh002@blueyond er.co.uk> wrote:
                  [color=blue]
                  >
                  >"Leor Zolman" <leor@bdsoft.co m> wrote in message
                  >news:ress30p63 cshtrr96pkrnvni 8idl875n14@4ax. com...[color=green]
                  >> On Thu, 26 Feb 2004 13:31:24 -0800, "E. Robert Tisdale"
                  >> <E.Robert.Tisda le@jpl.nasa.gov > wrote:
                  >>[color=darkred]
                  >> >Guybrush Threepwood wrote:
                  >> >
                  >> >> I was always wondering if there is any difference between
                  >> >>
                  >> >> void someFunction(in t, int)
                  >> >>
                  >> >> and
                  >> >>
                  >> >> void someFunction(in t A, int B)
                  >> >>
                  >> >> is there?
                  >> >
                  >> >The first can only be a declaration.
                  >> >The second could be the beginning of a definition.[/color]
                  >>
                  >> 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
                  >>[/color]
                  >
                  >There's even a common and reasonable use for a declaration and definition
                  >with no
                  >parameter name: operator++(int) - the post increment operator
                  >[/color]

                  Sure. I use the mechanism in at least three different places in each
                  version of my InitUtil library:

                  This page provides a list of the pages of BDSoft.com, and a little info about each one. If you are lost on our site, try using the sitemap to find what you are looking for.


                  In those cases, template parameters are only mined for their type
                  information.
                  -leor

                  Leor Zolman
                  BD Software
                  leor@bdsoft.com
                  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

                  Comment

                  Working...