#include <iostream> using namespace std; class Test{ private: static int val; int a; public: static int func(); static void sfunc(Test &r); }; int Test::val=20; int Test::func() { val+=val; return val; } void Test::sfunc (Test &r) { r.a=25; cout<<"Result3="<<r.a<<endl; } int main(){ cout <<"Resultl="<<Test::func()<<endl; Test a; cout<<"Result2="<<a.func()<<endl; Test::sfunc (a); return 0; }运行结果:
知识点总结:
static静态变量的初始化
学习心得:
好好学习 天天向上
原文地址:http://blog.csdn.net/ljd939952281/article/details/44901833