首页 > 代码库 > c/c++的*&调用

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:

1x=10x22fedc0x22fee4

 

c/c++的*&调用