64,654
社区成员
发帖
与我相关
我的任务
分享
class Singelton
{
private:
Singelton(){}
static Singelton* singel;
public:
static Singelton* GetInstance()
{
if(singel == NULL)
{
singel = new Singelton();
}
return singel;
}
};
Singelton* Singelton::singel = NULL;
客户端:
int main()
{
Singelton* s1=Singelton::GetInstance();
return 0;
}
class A
{
private:
A();
A(const A&);
public:
~A();
static A* GetA()
{
static A a;
return &a;
}
};
class B public:A
{
A * m_pA;
public:
B():m_pA(A::GetA())
{}
};
class A
{
private:
A(){}
A(const A&){}
public:
A(int a){}//有这个接口
~A(){}
};
//A类中不可以改动
class B :public A
{
//以下B的构造函数怎么写?
public:
B():A(0){}//error
B(int a):A(a){}// error
B(B*pc):A(0){}//error
};