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

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

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

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. James Vanns
    Replies:
    7
    Views:
    7,676
    Evan Carew
    Jan 21, 2004
  2. komal
    Replies:
    6
    Views:
    1,718
    msalters
    Jan 25, 2005
  3. Replies:
    2
    Views:
    1,137
    Bengt Richter
    Aug 1, 2005
  4. Giannis Papadopoulos

    Function pointer to void function and int function

    Giannis Papadopoulos, Sep 5, 2005, in forum: C Programming
    Replies:
    5
    Views:
    1,524
    Barry Schwarz
    Sep 5, 2005
  5. Andy Chambers
    Replies:
    1
    Views:
    518
    Daniel Dyer
    May 14, 2007
  6. weafon
    Replies:
    1
    Views:
    539
    Diez B. Roggisch
    Jul 14, 2009
  7. Alf P. Steinbach
    Replies:
    10
    Views:
    4,019
    Alf P. Steinbach
    Jul 27, 2011
  8. Richard A. DeVenezia
    Replies:
    4
    Views:
    341
    Lasse Reichstein Nielsen
    Sep 5, 2003
Loading...