山大课件 数据结构_1.ppt

  1. 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
山大课件 数据结构_1

* * * * * * The two most important concepts in object-oriented programming are the class and the object. In the broadest term, an object is a thing, both tangible and intangible, which we can imagine. A program written in object-oriented style will consist of interacting objects. For a program to maintain bank accounts for a bank, we may have many Account, Customer, Transaction, and ATM objects. An object is comprised of data and operations that manipulate these data. * * * This diagram shows three instances of the Employee class. Their names are Bill, Steve, and Andy. They are more commonly referred to as Employee objects. One key fact to remember: A class must be defined before you can create an instance (object) of the class. * Notice that the name of the message we send to an object or a class must be the same as the method’s name. Because they are the same, the message name is commonly omitted from the diagram as shown above. Because they are the same, the phrase “calling an object’s method” is synonymous to “sending a message to an object.” * The deposit method in the previous slide is an action-only method. It takes some action when called, but returns no answer back to the caller. The getMonthlyFee method above is a value-returning method. When called, it returns a value. A method can be both: executes an action and returns some value. * * 类的图形表示 Account 类的名字 方角矩形是一个类的图标 * * 实例的关系 Employee Employee Bill Employee Steve Employee Andy 这是为一个类创建了三个对象,在对象的图标中类的名字可省略。 虚线表示实例的关系。 在建立实例之前,类必需已经有定义。 * * 消息和方法 要让类的实例或对象完成一项任务,我们必需给它发送一个消息(message)。 消息只能发送给能够理解这个消息的类或对象。 所接受的消息,类或对象必需具有处理该消息的方法(method)。 传递给对象的数据称为消息变量(argument)。 发送new消息建立一个类的示例 * * 发送消息 给对象chk-008发送带有变量250.00的deposit消息 Account chk-008 deposit deposit 250.00 在图形中消息的名可以省略 deposit 250.00 * * 发送消息得到返回值 这个消息没有变量 Account chk-008 getMonthlyFee monthly fee monthly fee返回给消息发送者 * * class Currency { public: // 构造函数 Currency(sign s=plus,unsigned long d=0, unsigned int c=0); // 析构函数

文档评论(0)

wyjy + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档