定义全局变量浪费时间

#include<iostream>
using namespace std;
double a=22;
int main()
{
    //double a=22;
    double a1=a;
    a1=7;
    //cout<<a<<endl;
    //int a1={0};
    cout<<a1<<endl;
    return 0;

}

7


Process returned 0 (0x0)   execution time : 3.734 s
Press any key to continue.

int main()
{
    double a=22;
    double a1=a;
    a1=7;
    //cout<<a<<endl;
    //int a1={0};
    cout<<a1<<endl;
    return 0;

}

7


Process returned 0 (0x0)   execution time : 0.752 s
Press any key to continue.

以上可以比较出来全局变量耗时


你可能感兴趣的:(定义全局变量浪费时间)