#include"iostream"
using namespace std;
class s
{
class test
{
public:
static int a;
static int *b;
test(){printf("构造函数\n");}
~test(){printf("析构函数\n");}
void add(){printf("ok %d %d\n",a,*b);}
};
public:
static test t; //这2个东西怎么初始化
static test *t1;
};
s::test* s::t1=new s::test(); //调用构造
s::test s::t; //调用构造
int s::test::a=10;
int* s::test::b=new int(15);
int main(int argc, char const *argv[])
{
s::t.add();
s::t1->add();
cout<<"hello"<<endl;
return 0;
}
c++中的静态变量,静态指针,静态类指针,静态类对象使用和原理
最新推荐文章于 2024-05-16 16:10:19 发布