const function??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • franco ziade

    #1

    const function??

    what does this declaration mean?

    void function_name() const
    {}

    This means that the function is constant? what is the implication?

    Thanks


  • Tom St Denis

    #2
    Re: const function??


    franco ziade wrote:[color=blue]
    > what does this declaration mean?
    >
    > void function_name() const
    > {}
    >
    > This means that the function is constant? what is the implication?[/color]

    It means you have broken code. Did you even try to compile it?

    laptop ~ # gcc -Wall -W -O2 -c test.c
    test.c: In function `function_name' :
    test.c:2: error: parse error before '{' token

    I mean you might as well ask what

    for_lots_of_ite ms (int i = 0 through 3; while i < fourteen; add to i)
    display me i please;

    means...

    Tom

    Comment

    • Jens.Toerring@physik.fu-berlin.de

      #3
      Re: const function??

      franco ziade <fziade@videotr on.ca> wrote:[color=blue]
      > what does this declaration mean?[/color]
      [color=blue]
      > void function_name() const
      > {}[/color]
      [color=blue]
      > This means that the function is constant? what is the implication?[/color]

      Are you sure this is supposed to be C and not C++? If it is C++
      then you're in the wrong group, please ask in comp.lang.c++. In
      C this function declaration is a syntax error.

      Regards, Jens
      --
      \ Jens Thoms Toerring ___ Jens.Toerring@p hysik.fu-berlin.de
      \______________ ____________ http://www.toerring.de

      Comment

      • Emmanuel Delahaye

        #4
        Re: const function??

        franco ziade wrote on 25/02/05 :[color=blue]
        > what does this declaration mean?
        >
        > void function_name() const
        > {}[/color]

        Nothing. Parse error.

        --
        Emmanuel
        The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
        The C-library: http://www.dinkumware.com/refxc.html

        "Mal nommer les choses c'est ajouter du malheur au
        monde." -- Albert Camus.

        Comment

        • E. Robert Tisdale

          #5
          Re: const function??

          franco ziade wrote:
          [color=blue]
          > what does this declaration mean?
          >[/color]
          class X {
          public:[color=blue]
          > void function_name(v oid) const { }[/color]
          };[color=blue]
          >
          > This means that the function is constant? what is the implication?[/color]

          You are probably reading C++ code.
          It looks like a member function definition
          taken out of the context of the class definition.

          Comment

          • Jens.Toerring@physik.fu-berlin.de

            #6
            Re: const function??

            E. Robert Tisdale <E.Robert.Tisda le@jpl.nasa.gov > wrote:[color=blue]
            > franco ziade wrote:[color=green]
            >> what does this declaration mean?
            >>[/color]
            > class X {
            > public:[color=green]
            >> void function_name(v oid) const { }[/color]
            > };[color=green]
            >>
            >> This means that the function is constant? what is the implication?[/color][/color]
            [color=blue]
            > You are probably reading C++ code.
            > It looks like a member function definition
            > taken out of the context of the class definition.[/color]

            What's going on here? What Franco Ziade wrote was:

            || what does this declaration mean?
            ||
            || void function_name() const
            || {}
            ||
            || This means that the function is constant? what is the implication?

            What you're "citing" has three lines that never were in the post by
            Franco Ziade and of the rest you have "edited" one line. So why are
            you (again) "citing" something that has never been posted?
            --
            \ Jens Thoms Toerring ___ Jens.Toerring@p hysik.fu-berlin.de
            \______________ ____________ http://www.toerring.de

            Comment

            • Keith Thompson

              #7
              Re: const function??

              Jens.Toerring@p hysik.fu-berlin.de writes:[color=blue]
              > E. Robert Tisdale <E.Robert.Tisda le@jpl.nasa.gov > wrote:[color=green]
              >> franco ziade wrote:[color=darkred]
              >>> what does this declaration mean?
              >>>[/color]
              >> class X {
              >> public:[color=darkred]
              >>> void function_name(v oid) const { }[/color]
              >> };[color=darkred]
              >>>
              >>> This means that the function is constant? what is the implication?[/color][/color]
              >[color=green]
              >> You are probably reading C++ code.
              >> It looks like a member function definition
              >> taken out of the context of the class definition.[/color]
              >
              > What's going on here? What Franco Ziade wrote was:
              >
              > || what does this declaration mean?
              > ||
              > || void function_name() const
              > || {}
              > ||
              > || This means that the function is constant? what is the implication?
              >
              > What you're "citing" has three lines that never were in the post by
              > Franco Ziade and of the rest you have "edited" one line. So why are
              > you (again) "citing" something that has never been posted?[/color]

              If you look carefully, you'll see that ERT correctly marked the lines
              he added. In this followup, the OP's line is marked with ">>>", and
              the added lines with ">>" (though the original line didn't have the
              "{ }" that ERT added to it). He could have been clearer about what he
              was doing, though.

              --
              Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
              San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
              We must do something. This is something. Therefore, we must do this.

              Comment

              • CBFalconer

                #8
                Re: const function??

                Keith Thompson wrote:[color=blue]
                > Jens.Toerring@p hysik.fu-berlin.de writes:[color=green]
                >> E. Robert Tisdale <E.Robert.Tisda le@jpl.nasa.gov > wrote:[color=darkred]
                >>> franco ziade wrote:[/color][/color]
                >[color=green][color=darkred]
                >>>> what does this declaration mean?
                >>>>
                >>> class X {
                >>> public:
                >>>> void function_name(v oid) const { }
                >>> };
                >>>>
                >>>> This means that the function is constant? what is the implication?[/color]
                >>[color=darkred]
                >>> You are probably reading C++ code.
                >>> It looks like a member function definition
                >>> taken out of the context of the class definition.[/color]
                >>
                >> What's going on here? What Franco Ziade wrote was:
                >>
                >> || what does this declaration mean?
                >> ||
                >> || void function_name() const
                >> || {}
                >> ||
                >> || This means that the function is constant? what is the implication?
                >>
                >> What you're "citing" has three lines that never were in the post by
                >> Franco Ziade and of the rest you have "edited" one line. So why are
                >> you (again) "citing" something that has never been posted?[/color]
                >
                > If you look carefully, you'll see that ERT correctly marked the lines
                > he added. In this followup, the OP's line is marked with ">>>", and
                > the added lines with ">>" (though the original line didn't have the
                > "{ }" that ERT added to it). He could have been clearer about what
                > he was doing, though.[/color]

                Yes, I was ready to castigate also. However on NS 4.7x quoted
                material is in a different typeface than new material, so things
                stand out better. I guess ERT does so many trollish things that we
                are overly ready to discover another. Every time he shows signs of
                reforming he seems to fall off the wagon again. But this is not a
                fall :-)

                --
                "If you want to post a followup via groups.google.c om, don't use
                the broken "Reply" link at the bottom of the article. Click on
                "show options" at the top of the article, then click on the
                "Reply" at the bottom of the article headers." - Keith Thompson


                Comment

                • DHOLLINGSWORTH2

                  #9
                  Re: const function??


                  "franco ziade" <fziade@videotr on.ca> wrote in message
                  news:N4ETd.4128 8$6U2.867571@we ber.videotron.n et...[color=blue]
                  > what does this declaration mean?
                  >
                  > void function_name() const
                  > {}
                  >
                  > This means that the function is constant? what is the implication?
                  >
                  > Thanks
                  >
                  >[/color]

                  This means you expect us to read your programming manual for you.


                  Comment

                  • uououo

                    #10
                    Re: const function??

                    class foo{
                    public:
                    void bar();
                    };
                    void foo::bar()const { }


                    ////////////////////////////////////////

                    const foo a;
                    a.bar();///////////////////////////

                    Comment

                    • Jens.Toerring@physik.fu-berlin.de

                      #11
                      Re: const function??

                      CBFalconer <cbfalconer@yah oo.com> wrote:[color=blue]
                      > Keith Thompson wrote:[color=green]
                      >> Jens.Toerring@p hysik.fu-berlin.de writes:[color=darkred]
                      >>> E. Robert Tisdale <E.Robert.Tisda le@jpl.nasa.gov > wrote:
                      >>>> franco ziade wrote:[/color]
                      >>[color=darkred]
                      >>>>> what does this declaration mean?
                      >>>>>
                      >>>> class X {
                      >>>> public:
                      >>>>> void function_name(v oid) const { }
                      >>>> };
                      >>>>>
                      >>>>> This means that the function is constant? what is the implication?
                      >>>
                      >>>> You are probably reading C++ code.
                      >>>> It looks like a member function definition
                      >>>> taken out of the context of the class definition.
                      >>>
                      >>> What's going on here? What Franco Ziade wrote was:
                      >>>
                      >>> || what does this declaration mean?
                      >>> ||
                      >>> || void function_name() const
                      >>> || {}
                      >>> ||
                      >>> || This means that the function is constant? what is the implication?
                      >>>
                      >>> What you're "citing" has three lines that never were in the post by
                      >>> Franco Ziade and of the rest you have "edited" one line. So why are
                      >>> you (again) "citing" something that has never been posted?[/color]
                      >>
                      >> If you look carefully, you'll see that ERT correctly marked the lines
                      >> he added. In this followup, the OP's line is marked with ">>>", and
                      >> the added lines with ">>" (though the original line didn't have the
                      >> "{ }" that ERT added to it). He could have been clearer about what
                      >> he was doing, though.[/color][/color]
                      [color=blue]
                      > Yes, I was ready to castigate also. However on NS 4.7x quoted
                      > material is in a different typeface than new material, so things
                      > stand out better. I guess ERT does so many trollish things that we
                      > are overly ready to discover another. Every time he shows signs of
                      > reforming he seems to fall off the wagon again. But this is not a
                      > fall :-)[/color]

                      Sorry, I apologize to ERT on the count of adding lines. I don't on
                      the count of editing lines he's citing (there never was a 'void' in
                      the original post).
                      Regards, Jens
                      --
                      \ Jens Thoms Toerring ___ Jens.Toerring@p hysik.fu-berlin.de
                      \______________ ____________ http://www.toerring.de

                      Comment

                      Working...