Kiran's Blog

Ramblings from a dehydrated mind…

  • Archives

    • 14,907
  • Advertisements

function return values…

Posted by kiraninbng on July 18, 2006

Generally functions on success will return a value of 0,but i have often seen funtions which return a value of 1 for success,which i believe makes the function inextensible
for returning meaningful error codes.Heres what i follow,

typedef enum

RETURNTYPE SomeFunction()
  Result = FAILURE_N;


In simple terms return a value of 0(FALSE) for success and a value other than 0 for failure.


2 Responses to “function return values…”

  1. FarPointer said

    How about making the return type a class , so later you can query to find the
    1. the latest error
    2. to get a descriptive note by maintaining a map inside.
    3. And ofcourse its more object oriented ,enabling us to set different property for the error class.

  2. kiraninbng said

    Totally agree with you,returning an error object is far better solution for bigger and complex projects.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: