大家帮忙看一下这段代码有什么问题,我没找出来,复制函数和赋值函数还没有写,谢谢!
class Father
{
public:
Father()
{
m_nID=0;
printf("Father Construct\n");
}
~Father()
{
m_nID=0;
printf("Father Release\n");
}
protected:
int m_nID;
int m_nDataBytes; //m_pData的字节数
float* m_pData;
};
class Child: public Father
{
public:
Child()
{
m_nGrade=0;
printf("Child Construct\n");
}
~Child()
{
m_nGrade=0;
printf("Child Release\n");
}
static void Print(Child child)
{
printf("ID=%d,Grade=%d\n",child.m_nID,child.m_nGrade);
}
private:
int m_nGrade;
};
void Test()
{
Child* child=new Child();
Child::Print(*child);
}
void main()
{
Test();
} |