专注电子技术学习与研究
当前位置:单片机教程网 >> MCU设计实例 >> 浏览文章

C++函数参数传递例子

作者:佚名   来源:本站原创   点击数:  更新时间:2013年10月31日   【字体:
#include <stdio.h>
#include <iostream.h>
int qq(int x,int y)
{
return x*y;
}

 
void main()
{
int k=7;
cout<<qq(k++,++k)<<endl;
}


 


 

 #include <stdio.h>

#include <iostream.h>

int qq(int x,int y,int z,int p)

{


 

cout<<x<<endl;

cout<<y<<endl;

cout<<z<<endl;

cout<<p<<endl;

return x*y*z*p;

}


 

void main()

{

int k=2;


 

cout<<qq(++k,++k,++k,++k);

cout<<endl;


 

cout<<k;

}

 


 
分析:表达式分析(k++,++k)  因为VC是从右往左编译的,所以先计算++k ,然后才是k++


 

                            (++k,++k,++k,++k) 也是先从右往左编译。
      注:这种表达式和编译环境有关。
 
关闭窗口

相关文章