C++教程第07章 - 类与对象-1定义及使用初步(3)

2019-08-30 17:59

b.WithDraw(1002,8000); b.WithDraw(1003,2000); b.WithDraw(1002,2000); }

运行结果:

1001 After deposit,the balance is: 1000 1001 After witndraw,the balance is : 500 1001 After deposit,the balance is: 2500 1001 After witndraw,the balance is: 1500 1002 After deposit,the balance is: 5000 1002 After witndraw,the balance is : 3000 The amount to witndraw is bebyond the balance. Illegal account_number!

1002 After witndraw,the balance is :1000

可见,类CbankAccount中的所有成员数据都被封装起来,外部对象不能直接访问它们。但可以通过公有成员函数MakeDeposit()、WithDraw()对它们进行间接的访问。

11


C++教程第07章 - 类与对象-1定义及使用初步(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2016春高中英语Unit4Wildlifeprotection单元测评新人教版必修2

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: