Is it a good design to return value by parameter?
- by aztack
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?