int vs const int&
Posted
by
Valdo
on Stack Overflow
See other posts from Stack Overflow
or by Valdo
Published on 2011-01-16T13:27:21Z
Indexed on
2011/01/16
13:53 UTC
Read the original article
Hit count: 126
I've noticed that I usually use constant references as return values or arguments. I think the reason is that it works almost the same as using non-reference in the code. But it definitely takes more space and function declarations become longer. I'm OK with such code but I think some people my find it a bad programming style.
What do you think? Is it worth writing const int& over int? I think it's optimized by the compiler anyway, so maybe I'm just wasting my time coding it, a?
© Stack Overflow or respective owner