Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Returning an array in C++

Name: Anonymous 2009-10-26 20:39

PLEASE /prog/ help me out here. I've read and tested at least 5 "answers" to my question that I've found on google, but I can't get any of them to work. You guys are better than them though, right?

I wanted to call an array by reference in a function. Then, I learned that that was impossible. I tried returning the array, but you can't do that either.

Apparently, I need to do some shit with pointers to return the array. How the fuck do I do this?

Name: Anonymous 2009-10-26 21:34

Hey, morons, this is C++. Use new, not malloc.

>>1
In general, you want to let the caller allocate it and pass it in to the function, unless the function's sole purpose is to allocate an array and return it. This is because C++ memory management is from retardo-land. Same for C.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List