(1) 基类存在默认构造函数
class CBaseClass
{
public:
CBaseClass()
{
m_i = 0;
}
private:
int m_i;
};
class CDriveClass: public CBaseClass
{
public:
void func()
{
}
private:
};
(2) 成员变量存在默认构造函数
class CTestClass
{
public:
CTestClass()
{
m_i = 1;
}
private:
int m_i;
};
class CDriveClass
{
public:
void func()
{
}
private:
CTestClass mTestClass;
};
(3) 存在虚函数:初始化虚函数指针
class CDriveClass: virtual public CBaseClass //: public CBaseClass
{
public:
void func()
{
}
};
(4) 存在虚基类:初始化虚基类指针
class CBaseClass
{
};
class CDriveClass: virtual public CBaseClass
{
public:
void func()
{
}
};
具体可以查看反汇编代码:Visual Stdio 2010编译器中:Debug->windows->Disassembly
--汇编代码
CDriveClass d;
002613DE push 1
002613E0 lea ecx,[d]
002613E3 call CDriveClass::CDriveClass (261136h)
时间: 2024-10-11 05:19:49