Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualKhatharr

Posted 06 February 2013 - 08:11 PM

LOL, the thread is tagged "C Language" but you're using C++ there.

I find it useful to use return codes for indicating error states or information about what the function did. Handling objects by reference or pointer not only frees up the return value but allows you a consistent means for when you want to pass more than one object.

Another thing to consider in cases like this - and I'm not implying that you don't already have it right in this case - is whether this function should be a member of the class/struct or remain as an outside function.

#1Khatharr

Posted 06 February 2013 - 07:58 PM

LOL, the thread is tagged "C Language" but you're using C++ there.

 

I find it useful to use return codes for indicating error states or information about what the function did. Handling objects by reference or pointer not only frees up the return value but allows you a consistent means for when you want to pass more than one object.

 

It's usually not a great idea to instantiate an object in an argument list. You have no means of accessing it afterwards unless you create a kind of reference tunnel by accepting the object by reference and then returning a reference to the same object. That would be needlessly complex and you'd run into an immediate problem if you wanted to pass-through more than one object.

 

Another thing to consider in cases like this - and I'm not implying that you don't already have it right in this case - is whether this function should be a member of the class/struct or remain as an outside function.


PARTNERS