c/c++的*&调用
时间:2014-10-08 14:42:55
收藏:0
阅读:221
#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
评论(0)