|
-
December 27th, 2003, 10:38 AM
#10
I'm also new to C++ coming from Java.
One source of confusion is that Java has call by value only. C and Java has call by value only, Fortran has call by reference only, but Pascal and C++ has a mixed calling mechanism.
When someone from Java says she's passing something by reference she actually means she's passing a reference by value.
So in this case what the OP, coming from Java, actually asks is how can I create a collection in a function, and then pass it back to the calling function without copying. The reason is efficiency. If you create say 1 million integers in an STL container in a function you don't want it to be copied back to the calling function. What you want back is a pointer (a reference) to the collection.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|