behaviour of a function

Discussion in 'C++' started by subramanian100in@yahoo.com, India, Sep 20, 2007.

  1. , India

    , India Guest

    Kindly explain what is meant by behaviour of a function ? Does it mean
    what task the function performs - say for example finding the square
    root of a function Or does it mean how a function performs the task,
    that is, the way of accomplishing a task

    Kindly give the body of a function explaining what is meant by
    behaviour of a function.

    Thanks
    V.Subramanian
     
    , India, Sep 20, 2007
    #1
    1. Advertising

  2. wrote:
    > Kindly explain what is meant by behaviour of a function ? Does it mean
    > what task the function performs - say for example finding the square
    > root of a function Or does it mean how a function performs the task,
    > that is, the way of accomplishing a task
    >
    > Kindly give the body of a function explaining what is meant by
    > behaviour of a function.


    Read about "return values" and "side effects". If the function does
    not have any of those, it has no behaviour.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Sep 20, 2007
    #2
    1. Advertising

  3. , India

    , India Guest

    On Sep 20, 8:44 am, "Victor Bazarov" <> wrote:
    > wrote:
    > > Kindly explain what is meant by behaviour of a function ? Does it mean
    > > what task the function performs - say for example finding the square
    > > root of a function Or does it mean how a function performs the task,
    > > that is, the way of accomplishing a task

    >
    > > Kindly give the body of a function explaining what is meant by
    > > behaviour of a function.

    >
    > Read about "return values" and "side effects". If the function does
    > not have any of those, it has no behaviour.
    >
    > V
    > --
    > Please remove capital 'A's when replying by e-mail
    > I do not respond to top-posted replies, please don't ask


    May I request you to give example function bodies for these for me to
    understand the behaviour.

    Please excuse me if I am wrong in asking it.

    Thanks
    V.Subramanian
     
    , India, Sep 21, 2007
    #3
  4. , India

    Kai-Uwe Bux Guest

    , India wrote:

    > On Sep 20, 8:44 am, "Victor Bazarov" <> wrote:
    >> wrote:
    >> > Kindly explain what is meant by behaviour of a function ? Does it mean
    >> > what task the function performs - say for example finding the square
    >> > root of a function Or does it mean how a function performs the task,
    >> > that is, the way of accomplishing a task

    >>
    >> > Kindly give the body of a function explaining what is meant by
    >> > behaviour of a function.

    >>
    >> Read about "return values" and "side effects". If the function does
    >> not have any of those, it has no behaviour.
    >>
    >> V
    >> --
    >> Please remove capital 'A's when replying by e-mail
    >> I do not respond to top-posted replies, please don't ask

    >
    > May I request you to give example function bodies for these for me to
    > understand the behaviour.

    [snip]

    This is a function with a return value:

    int four ( void ) {
    return ( 4 );
    }

    This is a function with a side effect:

    void make_four ( int & i ) {
    i = 4;
    }

    This is a function with a side effect that you cannot tell from the
    signature:

    void log_error_4 ( void ) {
    std::cerr << "Encountered Error 4. Don't ask what that means.\n";
    }


    Best

    Kai-Uwe Bux
     
    Kai-Uwe Bux, Sep 21, 2007
    #4
    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. Shailan
    Replies:
    2
    Views:
    1,108
    Shailan
    Dec 15, 2003
  2. muser
    Replies:
    9
    Views:
    332
    Rolf Magnus
    Oct 14, 2003
  3. eddiew_AUS
    Replies:
    18
    Views:
    649
    Andrey Tarasevich
    Jan 27, 2004
  4. Fabiano Sidler

    Inexplicable behaviour of <type 'function'>

    Fabiano Sidler, Apr 23, 2006, in forum: Python
    Replies:
    1
    Views:
    292
    Leif K-Brooks
    Apr 23, 2006
  5. Andy Chambers
    Replies:
    1
    Views:
    401
    Daniel Dyer
    May 14, 2007
Loading...

Share This Page