c/c++的*&调用

#define LOCAL
#include<cstdio>
#include<iostream>
using namespace std;
typedef int ElemType;
void fun1(ElemType *x)
{
    cout<<"x="<<(*x)<<endl;
}
void fun2(ElemType *&x)
{
    x=x+2;
}
int main()
{
#ifdef LOCAL
    freopen("1.in","r",stdin);
    freopen("1.out","w",stdout);
#endif    
    ElemType a;
    ElemType *b;
    cin>>a;
    cout<<(*&a)<<endl;
    fun1(&a);
    b=&a;
    cout<<b<<endl;
    fun2(b);
    cout<<b<<endl;//存储单元加一 
    return 0;
}

result:

1
x=1
0x22fedc
0x22fee4
原文地址:https://www.cnblogs.com/jianfengyun/p/4010999.html