云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > C++面向对象程序设计教程(第3版)—-陈维兴,林小茶课后习题答案

C++面向对象程序设计教程(第3版)—-陈维兴,林小茶课后习题答案

  • 62 次阅读
  • 3 次下载
  • 2025/5/23 17:45:45

Default constructor called. Default constructor called. Construcotor:a=1,b=2 Construcotor:a=3,b=4 Construcotor:a=5,b=6

1.32

Con. Copy con. default. Copy con.

1.33

A=5 B=14 A=9 B=14

1.34

5,7 8.

1.35

Constructing

Constructing A=5 B=15 A=10 B=15 Destructing Destructing

1.36

void pintStu(); 函数只有声明,没有定义。

age

是私有成员,不能用对象直接调用。

1.37

void printStu() 和 void setSno(int s) 没有加限定符void setAge(int a)

在类中没有声明

1.38

构造函数不能定义为私有。否则无法创建对象。

1.39 下面是一个计算器类的定义,请完成该类成员函数的实现。

class counter {

public :

counter( int number); void increment();

// 给原始值加 1

Student::

void decrement(); int getvalue(); int print(); private :

int value; };

counter::counter( int number) // 给原始值减 1 // 取的计数器值 // 显示计数

{

value = number; }

void counter::increment() {

++value; }

void counter::decrement() {

--value; }

int counter::getvalue() {

return value; }

int counter::print() {

cout << value <

1.40 根据注释语句提示,实现类

#include using namespacestd; class Date {

public :

void printDate();

void setDay( int d); void setMonth( int m); void setYear( int y);

的成员函数

Date private :

int day, month, year; };

void Date::printDate() {

cout << \今天是\<< year << \年\<< month << \月\<< day << \日\<< endl; }

void Date::setDay( int d) {

day = d; }

void Date::setMonth( int m) {

month = m; }

void Date::setYear( int y) {

year = y; }

int main() {

Date testDay; testDay.setDay( 5); testDay.setMonth( 10); testDay.setYear( 2003); testDay.printDate(); return 0; }

1.41 建立类 cylinder, cylinder 的构造函数被传递了两个 高度。用类 cylinder 计算圆柱体的体积,并存储在一个 一个成员函数 vol,用来显示每个 cylinder 对象的体积。const int PI = 3.14 ;

class cylinder {

private :

double radius, height, volume; public :

double 值,分别表示圆柱体的半径和

double 变量中。在类 cylinder 中包含

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

Default constructor called. Default constructor called. Construcotor:a=1,b=2 Construcotor:a=3,b=4 Construcotor:a=5,b=6 1.32 Con. Copy con. default. Copy con. 1.33 A=5 B=14 A=9 B=14 1.34 5,7 8. 1.35 ConstructingConstructing A=5 B=15 A=10 B=15 Destructing Destructing 1.36 void pintStu(); 函数只有声明,没有定义。 age 是私

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com