lundi 22 janvier 2018

Generally, is dereference pointer expression results a reference type?

Deferencing pointer leads to using the value of the object indirectly. But I've never really understood what does the "using" means. I started to think the question until my compiler yield an error for the following code

int i = 0, *pi = &i;
decltype(*pi) = c; // error: 'c' declared as reference but not initialized.

I looked at the error for a very long time and searched some questions I can only give out the following arguments. I don't know if they are correct or not.

Arguments 1:

1) *p is an expression that is not a variable (or non-variable expression)

2) dereferencing pointer expression yields a reference, we are in fact using a reference to access the value of the object

Arguments 2:

the dereferencing expression only for which decltype returns a reference, it is not a general case

Please points out any incorrectness or inaccurate descriptions of the above arguments.

Aucun commentaire:

Enregistrer un commentaire