#include<iostream>
#include<stdio.h>
using namespace std;
class static_name
{
public:
static_name(){};
static int static_print();
private:
static int i_static_value;
};
int static_name::static_print()
{
printf("This is static!! i_static_value = %d\n", i_static_value);
return 1;
}
int static_name::i_static_value = static_name::static_print();
int main()
{
printf("This is main_function()!!\n");
return 0;
}
证明静态函数在main函数运行前就运行了
最新推荐文章于 2019-10-31 11:00:31 发布