behaviour of a function

S

subramanian100in

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
 
V

Victor Bazarov

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
 
S

subramanian100in

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

V

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
 
K

Kai-Uwe Bux

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top