This question already has an answer here:
Given this code:
int& some_class::ret_ref(){
return this->some_integer;
}
int* some_class::ret_ptr(){
return &(this->some_integer);
}
int main(){
some_class c;
auto p=c.ret_ptr();
auto r=c.ret_ref();
}
At compile time:
p
isint*
r
isint
Why was auto
deduced as int*
in p
and it was not deduced as int&
in r
?
What is the rule here?
Aucun commentaire:
Enregistrer un commentaire