c++ - Passsing primitives by value -
i'm reading scott meyrses c++ , section passing-reference-to-const
. said user-defined types it's pass references-to-const, unlike built-in types.
my question why built-in types should passed value. why more efficient? think, put registers, reason?
when pass reference, behind scenes it's passing pointer. more efficient passing whole structure, large.
primitive types same size pointer (at worst might twice big). smaller -- char
1 byte, while pointers typically 4 or 8 bytes. there's no efficiency gained passing reference instead of passing value itself.
Comments
Post a Comment