Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the different between *&aPtr and &*aPtr?

Tags:

c++

pointers

I want to know what is the different between *&aPtr and &*aPtr if replaced * & and & * ?

int a;   
int *aptr;  
a = 7;     
aptr=&a;

cout << &* aPtr<< *&aPtr<< endl;
like image 490
Amal.aa Avatar asked Dec 19 '22 21:12

Amal.aa


1 Answers

They have the same value, but *&aPtr is an lvalue that refers to aPtr whereas &*aPtr is a prvalue that has the same value as aPtr.

like image 96
Brian Bi Avatar answered Dec 21 '22 11:12

Brian Bi