面向对象程序设计(谭浩强版)要点
7.2.2 构造函数和析构函数(续) class N:public M { public: N() {n=0;} N(int i,int j,int k); ~N(); void Print(); private: int n; }; M::M(int i,int j,int k):M(i,j),n(k) { coutNs costructor called. nendl; } N::~N() { 7.2.2 构造函数和析构函数(续) coutNs destructor called. nendl; } void N::Print() { M::Print(); coutnendl; } void main() { N n1(5,6,7), n2(-2,-3,-4); n1.Print(); n2.Print(); } 输出: Ms constructor called.5,6 Ns constructor called.7 Ms constructor called.-2,-3 Ns constructor called.-4 5,6,7 -2,-3,-4 Ns destructor called.-4 Ms destructor cal
您可能关注的文档
最近下载
- 第八讲共奉中国与中华民族内聚发展辽宋夏金时期01课件讲解.pptx VIP
- TC7525-16塔式起重机电控说明书.pdf
- 汽车车内空调流场分析与优化.docx VIP
- 船长见习记录薄附页(见习报告)(最全).doc VIP
- WW╱ T 0075-2017 田野考古钻探记录规范.pdf VIP
- 2023年成都天府新区投资集团有限公司招聘考试试题及答案解析.docx VIP
- 2022年成都天府新区投资集团有限公司招聘考试题库及答案解析.docx VIP
- 2026四川成都天府新区投资集团有限公司招聘产业投资岗等岗位47人笔试备考试题及答案解析.docx VIP
- 中华民族共同体概论大讲堂课件第七讲华夷一体与中华民族空前繁盛(隋唐五代时期).pptx VIP
- 2026四川成都天府新区投资集团有限公司招聘产业投资岗等岗位47人备考题库及答案详解一套.docx VIP
原创力文档

文档评论(0)