C++ 静态成员变量和类方法示例
#include
class Test{ public: static int x; Test(int i=0){ x=i+x; } int Getnum(){ return Test::x+10; } };
int Test::x = 30;
int main(){ Test test; cout << test.Getnum() << endl; system('pause'); return 0; }
原文地址: https://www.cveoy.top/t/topic/oX3y 著作权归作者所有。请勿转载和采集!