*\\\\&与\\\\&*的区别
时间: 2023-12-26 07:28:30 浏览: 52
在C++中,`*`和`&`是指针操作符,用于操作指针变量。`*`用于解引用指针,即获取指针所指向的值,而`&`用于获取变量的地址。
`*\\&`表示解引用一个指向指针的指针,即获取指向指针的指针所指向的值。而`\\&*`表示获取指针的指针所指向的地址。
以下是一个示例代码来演示`*\\&`和`\\&*`的区别:
```cpp
#include <iostream>
using namespace std;
int main() {
int a = 123;
int* p = &a;
int** pp = &p;
cout << "a的值为:" << a << endl;
cout << "p的值为:" << p << endl;
cout << "*p的值为:" << *p << endl;
cout << "pp的值为:" << pp << endl;
cout << "*pp的值为:" << *pp << endl;
cout << "**pp的值为:" << **pp << endl;
return 0;
}
```
输出结果为:
```
a的值为:123
p的值为:0x7ffeeb3e4a2c
*p的值为:123
pp的值为:0x7ffeeb3e4a30
*pp的值为:0x7ffeeb3e4a2c
**pp的值为:123
```
可以看到,`*\\&`操作得到的是指针所指向的值,而`\\&*`操作得到的是指针的地址。