From the desk of ARK:
Why Would You Ever Pass a Container By Value?
by Andrew Koenig
From the article:
Consider two fundamental features of C++: functions and references. Which shall we teach first?
If we teach references first, there is the problem of coming up with interesting example programs that use references but completely avoid user-defined functions. This is hard to do because the most common use of references is as function parameters — so it's probably easier to teach functions first.
However, if we teach functions before we teach references, then every function we write must accept its arguments by value — references not yet being available as an alternative...
Add a Comment
Comments are closed.