samedi 2 janvier 2016

what is the difference between int &val2 = val and int val3 = val? [duplicate]

This question already has an answer here:

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;

Aucun commentaire:

Enregistrer un commentaire