回楼上
#include<iostream>using namespace std;
class SingleObj{
public:
static SingleObj* GetSingleObj();
void dump() const{
cout<<"this is singleobj.."<<endl;
}
private:
SingleObj(){};
SingleObj(SingleObj &a){}
static SingleObj *obj;
};
SingleObj* SingleObj::obj=new SingleObj();//这里知道怎么解释吗?
SingleObj* SingleObj::GetSingleObj() {
return obj;
}
int main(void)
{
SingleObj::GetSingleObj()->dump();
SingleObj obj_(*SingleObj::GetSingleObj());
obj_.dump();
return 0;
}
学习需要安静。。海盗要重新来过。。