64,637
社区成员
发帖
与我相关
我的任务
分享
class B;
class A
{
B* m_pB;
public:
A(B* pB)
{
m_pB = pB;
}
};
class B
{
A a;
public:
B() : a(this)
{
}
};
int _tmain(int argc, _TCHAR* argv[])
{
B a;
return 0;
}
// C4355.cpp
// compile with: /W1 /c
#include <tchar.h>
class CDerived;
class CBase {
public:
CBase(CDerived *derived): m_pDerived(derived) {};
~CBase();
virtual void function() = 0;
CDerived * m_pDerived;
};
class CDerived : public CBase {
public:
CDerived() : CBase(this) {}; // C4355 "this" used in derived c'tor
virtual void function() {};
};
CBase::~CBase() {
m_pDerived -> function();
}
int main() {
CDerived myDerived;
}