文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > 高等教育 > 工学 > C++语言程序设计(清华大学出版社)课后习题及答案 第 五 章 程序的结构
侵权投诉

C++语言程序设计(清华大学出版社)课后习题及答案 第 五 章 程序的结构

我们老师给的习题及参考答案

void TelepathicFunction(); int main() {

const int MaxCats = 5;

Cat *CatHouse[MaxCats]; int i; for (i = 0; i<MaxCats; i++) {

CatHouse[i] = new Cat(i); TelepathicFunction(); }

for ( i = 0; i<MaxCats; i++) {

delete CatHouse[i]; TelepathicFunction(); } return 0; }

void TelepathicFunction() {

cout << "There are " << Cat::GetHowMany() << " cats alive!\n"; }

程序运行输出: There are 1 cats alive! There are 2 cats alive! There are 3 cats alive! There are 4 cats alive! There are 5 cats alive! There are 4 cats alive! There are 3 cats alive! There are 2 cats alive! There are 1 cats alive! There are 0 cats alive!

5-8 什么叫做友元函数?什么叫做友元类?

解:

友元函数是使用friend关键字声明的函数,它可以访问相应类的保护成员和私有成员。友元类是使用friend关键字声明的类,它的所有成员函数都是相应类的友元函数。

上一页第4页

你可能喜欢

  • 程序设计教程习题答案
  • 面向对象程序设计期末考试试题
  • C程序设计(第四版)谭浩强
  • 语言分析
  • 计算机二级C语言程序设计
  • PIC单片机C语言程序设计
  • C语言程序设计课程设计报告
  • C语言程序设计试题及答案

热门文档

相关文档

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email