Distinction between a method and a member function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Julián Albo

    #16
    Re: Distinction between a method and a member function

    Howie escribió:
    [color=blue]
    > a method is like a "function" but without a return value.[/color]

    That thing is called "procedure" in languages that makes the difference.

    Regards.

    Comment

    • White Wolf

      #17
      Re: Distinction between a method and a member function

      Tim Martin wrote:[color=blue]
      > Hi,
      >
      > I came across a detail in "C++ Gotchas" by Stephen Dewhurst that
      > confused me a bit. The author states:
      >
      > 'C++ has no "methods." Java and Smalltalk have methods. When you talk
      > about an object-oriented design and are feeling particularly
      > pretentious, you may use the terms "message" and "method," but when
      > you get down to discussing a C++ implementation of your design, use
      > the terms "function call" and "member function."'
      >
      > What he doesn't say is what the difference between a method and a
      > member function is.
      >
      > Furthermore, I've looked through the C++ FAQ and the archive of this
      > group, and neither mention the distinction. Quite a few posts in this
      > group do seem to use the terms interchangably.
      >
      > Can anyone explain briefly what the difference is?[/color]

      The difference is that method is an OO term and there is no well defined
      meaning for in when you talk about C++. Some understands it as any member
      function. Some others understand it only as virtual member functions. In
      fact - if we take the original OO meaning - non-member operator functions
      (found by ADL) should also be called methods in C++, since they *are* part
      of the classes interface, they just happen to be implemented as a non-member
      function for technical reasons.

      C++ really has no methods. It is a terminology aspect. Since what methods
      mean in a C++ implementation context might be ambiguous it helps if this
      term is not used in that context. Of course this is not a law, it is just
      common sense: helps to avoid misunderstandin gs. For example if you ask the
      question: what methods does C++ generate automaticly? some might answer:
      none. Since while you have meant "member functions" when saying "method"
      those answering meant "virtual member functions" when they have read
      "methods".

      --
      WW aka Attila


      Comment

      • Kevin Goodsell

        #18
        Re: Distinction between a method and a member function

        Howie wrote:[color=blue]
        > I just thought:
        >
        > a method is like a "function" but without a return value.[/color]

        In some languages that would be a 'procedure'. I've never heard it
        called a 'method' before.

        In any case, C++ has functions. Whether they return a value or not,
        whether they are a member or not, they are always called functions.
        That's just the way the language has always been described.

        -Kevin
        --
        My email address is valid, but changes periodically.
        To contact me please use the address from a recent posting.

        Comment

        • Ron Natalie

          #19
          Re: Distinction between a method and a member function


          "Kevin Goodsell" <usenet1.spamfr ee.fusion@never box.com> wrote in message news:3f560be1@s hknews01...[color=blue]
          > Howie wrote:[color=green]
          > > I just thought:
          > >
          > > a method is like a "function" but without a return value.[/color]
          >
          > In some languages that would be a 'procedure'. I've never heard it
          > called a 'method' before.
          >[/color]
          The common computer science definition of a method is an action performed
          on an object. Therefore, they are usually implemented in C++ as non-static
          member functions, although not all member functions in C++ are used as methods.

          Anyhow, the term is outside the C++ language.


          Comment

          • Shane Beasley

            #20
            Re: Distinction between a method and a member function

            Howie <howieh@webb.de > wrote in message news:<b10blvkpd mkun6jeuj30uaap hrbaji3nda@4ax. com>...
            [color=blue]
            > a method is like a "function" but without a return value.[/color]

            You're probably thinking "subroutine " or "procedure. " "method" is most
            definitely an OOP term, most properly associated with virtual
            functions in C++ (although it is occasionally [perhaps erroneously]
            used to describe non-virtual, non-static member functions as well):

            <http://www.nightflight .com/foldoc-bin/foldoc.cgi?meth od>
            <http://www.nightflight .com/foldoc-bin/foldoc.cgi?subr outine>

            - Shane

            Comment

            • Mark Sicignano

              #21
              Re: Distinction between a method and a member function

              I don't know where I first heard this, or if it's even correct, but I had
              understood an "operation" to be something that you do to an object, and the
              "method" is the particular implementation that gets called when the object
              is asked to perform the operation.

              For example, you might define Shape as having a Draw() "operation" (defined
              as pure virtual), and objects such as Square, Circle and Rectangle would
              provide their own "methods" to implement the Draw() operation.

              Of course in C++, you declare and/or define operations and methods by
              writing "member functions".

              To earlier posters, I don't see anything pretentious about using the word
              method. Makes perfect sense to me to use it in the context that I provided
              above. The implementation of the Draw() operation for the Square uses a
              different method to getting the job done than that of the Circle. Square and
              Rectangle use very similar methods to implement the Draw operation.

              -mark


              Comment

              Working...