帮忙看下为么calc2没内联上????
#include<iostream> #include<time.h> //#include<time>就编译不行,为什么????
using namespace std;
//---------------------
int calc1(int a,int b){return a+b;}
inline int calc2(int a,int b){return a+b;}
//---------------------------------
void main()
{
int x[1000],y[1000],z[1000];
int i,j,k;
clock_t t=clock();
for(i=0;i<1000;i++)
for(j=0;j<1000;j++)
for(k=0;k<1000;k++)
z[i]=calc1(x[j],y[k]);
cout<<"not using inline:"<<(clock()-t)/CLK_TCK<<"seconds.\n";//在VC++6.0中硬件每1000个滴答是一秒,clk_tck值为1000.
t=clock();
for(i=0;i<1000;i++)
for(j=0;j<1000;j++)
for(k=0;k<1000;k++)
z[i]=calc2(x[j],y[k]);
cout<<"using inline1:"<<(clock()-t)/CLK_TCK<<"seconds.\n";
}