64,643
社区成员
发帖
与我相关
我的任务
分享
void set_print_weight(int nTmpWeight) // 修改
{
set_weight(nTmpWeight); //这么使用
this->m_strName = m_strName;
int nTrueWeight = get_weight();
cout << m_strName << ", weight = "<< nTrueWeight;
}
private:
string m_strName;
};
int main()
{
Cat cat("Persian"); //定义派生类对象cat
cat.set_print_age();
cat.set_print_weight(12); //派生类对象调用自己的公有函数
return 0;
}
int get_weight()
{
return m_nWeightBase;
}
void set_age(int nAgeBase)
{
m_nAgeBase=nAgeBase;
}