- #include<iostream>
 
 - using namespace std;
 
  
- int a=1;
 
 - int dx(int x,int y)
 
 - {
 
 -         cout<<"dx"<<endl;
 
 -         a=100;
 
 -     cout<<x<<endl;
 
 -     if(x>y) return x;
 
 -     else return y;
 
 -         
 
 - }
 
  
- int fx(int x,int y)
 
 - {
 
 -         cout<<"fx"<<endl;
 
 -         return 0;
 
 - }
 
  
- int main()
 
 - {
 
 -         cout<<dx(a,6)<<fx(0,1);
 
 -         return 0;
 
 -  } 
 
  复制代码 程序输出: 
fx 
dx 
1 
60 
 
为什么先执行的fx函数? c/c++在函数调用时,默认都是右序入栈,导致先执行fx,返回结果入栈,再执行dx,返回结果入栈,然后再从栈中取出输出。  
 |