码迷,mamicode.com
首页 > 编程语言 > 详细

c/c++的*&调用

时间:2014-10-08 14:42:55      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   os   sp   div   c   on   

#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

 

c/c++的*&调用

标签:style   blog   color   io   os   sp   div   c   on   

原文地址:http://www.cnblogs.com/jianfengyun/p/4010999.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!