程序完成后的运行结果为:100
#include
using namespace std;
class Singleton
{
public:
int gld;
static Singleton* getInstance()
{
if(instance==NULL) instance=new Singleton();
return instance;
}
private:
Single
程序完成后的运行结果为:100
#include
using namespace std;
class Singleton
{
public:
int gld;
static Singleton* getInstance()
{
if(instance==NULL) instance=new Singleton();
return instance;
}
private:
Singleton() { }
static Singleton* instance;
};
________(1)__________
int main()
{
_________(2)_________
p->gld=100;
cout<gld;
return 0;
}
【正确答案】:(1)Singleton*Singleton::instance=NULL;【2分】
(2)Singleton*p=Singleton::getInstance();【2分】
Top