Ask HN: How come pass-by-reference is not the default in C++?
https://news.ycombinator.com/item?id=39507264I recently learned the concept of pass-by-reference where instead of copying data into a function’s parameter, you simply give it the address of where the variable being passed is located in memory.
In C++ you have to explicitly define that you want to pass by reference instead of value. Would it not be more efficient to use pass by reference by default since you’re not duplicating data in memory potentially for no real reason?