Is it a good design to return value by parameter?
Posted
by aztack
on Stack Overflow
See other posts from Stack Overflow
or by aztack
Published on 2010-03-16T07:37:49Z
Indexed on
2010/03/16
7:46 UTC
Read the original article
Hit count: 150
c++
bool is_something_ok(int param,SomeStruct* p)
{
bool is_ok = false;
// check if is_ok
if(is_ok)
// set p to some valid value
else
// set p to NULL
return is_ok;
}
this function return true and set p to a valid value if "something is ok" otherwise return false and set p to NULL
Is that a good or bad design? personally, i feel uncomfortable when i use it. If there is no document and comment, i really don know how to use it.
BTW:Is there some authoritative book/article about API design?
© Stack Overflow or respective owner