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

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -