What is value semantics and reference semantics and what is the difference between them? Can you please show me with an example in c. I guess in reference semantics that you just send an pointer to another function then it is reference semantics? I find it hard to grasp what value semantics is? If I only use an int as an argument and then let say return an int from that function then the function uses value semantics? And how does side effects affect this? There must be other examples of value semantics then I mentioned if I were right about it. Can you please give me examples of that. If a function takes a pointer as argument and the functions return value is an int, does the function make use of both reference- and value semantics?
asked Nov 23, 2014 at 0:04 user2682811 user2682811 185 1 1 gold badge 2 2 silver badges 5 5 bronze badges Commented Nov 23, 2014 at 0:09Value semantic means that you access a copy, while reference semantic means that you access the actual thing. The closest thing to reference semantic is passing an array to a function or passing a pointer.