Dear Matt,
> Returning an STL container from a function is valid, but it will give you a
> performance decrease. Every time you call this function, a new container is
> created, filled, and then returned, upon which the entire container gets
> copied over to the destination (element by element). Can't really recommend
> a better way to solve it though, I usually lay my designs out differently :)
As Paul has mentioned, it is hard to recommend anything. But just in case you want to
adhere to your design, which I doubt to be a good choice, the member function could return
a "reference" or "reference to constant" to the stack you are working with. This again
depends to how you may want to use the returned stack. I presume that you know that this
tends to saves you a lot!
Regards,
--Hossein
--
__________________________________________________________
Sign-up for your own personalized E-mail at Mail.com
http://www.mail.com/?sr=signup
CareerBuilder.com has over 400,000 jobs. Be smarter about your job search
http://corp.mail.com/careers
|