我这里有个Singleton模式的类,出现了内存泄露,但是删除不了,请问怎么解决问题?
class A;class B
{
public:
A *GetA();
static B& Instance();
void SetA(const CString &strTitle);
private:
static B* _B;
CString strPath;
A *_A;
B();
virtual ~B();
B(const B&);
B& operator=(const B&);};
B::B()
{
this->A=new A;
}
B& B::instance()
{
if(!_B)
_B=new B;
}
class A;class B
{
public:
A *GetA();
static B& Instance();
void SetA(const CString &strTitle);
private:
static B* _B;
CString strPath;
A *_A;
B();
virtual ~B();
B(const B&);
B& operator=(const B&);};
B::B()
{
this->A=new A;
}
B& B::instance()
{
if(!_B)
_B=new B;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货