0

I'm new to C++ and is trying to learn the concept of reference. Could someone please tell me what is the difference between int &val2 = val and int val3 = val?

I understand that I am creating a reference to val with &val2 (val2 is not an object, but merely a reference to an object). Is it the same with val3? Or am I creating something completely different?

int val = 1034;

int &val2 = val;
int val3 = val;
Thor
  • 9,638
  • 15
  • 62
  • 137

0 Answers0