Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualÁlvaro

Posted 11 July 2013 - 03:53 PM

You either get the user to pass you the array (what you had), return the address of a global object or return an object that wraps the array. The last one is probably what I would go for. You seem to be using float[3] to represent points. Make a class Point instead, and return that.

EDIT: Yes, you could also return a dynamically allocated buffer, which is what you did in your second post. But then the calling code needs to remember to delete[] it, and they don't, and this is how you create memory leaks.

#1Álvaro

Posted 11 July 2013 - 03:52 PM

You either get the user to pass you the array (what you had), return the address of a global object or return an object that wraps the array. The last one is probably what I would go for. You seem to be using float[3] to represent points. Make a class Point instead, and return that.

PARTNERS