0

Lets say we have the following code that doesn't use references:

int val = 5;
int val2 = func(val);

int func(int v) {
   return v * v;
}

Would the code be better with using references? I understand the difference between pointers and references, but not when to use references as opposed to not use them.

osk
  • 790
  • 2
  • 10
  • 31
  • This question doesn't make any sense, it's like 'should I swim in the pool or should I take a cup of coffee. Different scenarios call for different techniques. – SergeyA Mar 09 '16 at 14:23
  • Yes but what is the difference? When do you want to use references and when are they not neccessary? – osk Mar 09 '16 at 14:24
  • See [this](http://stackoverflow.com/questions/7058339/when-to-use-references-vs-pointers) and [this](http://stackoverflow.com/questions/373419/whats-the-difference-between-passing-by-reference-vs-passing-by-value). Also with something like an int passing by reference or value will normally not make a difference. – NathanOliver Mar 09 '16 at 14:24

0 Answers0