软件设计课件:Lecture 04 Fundamentals of OOP Object and Class.pptVIP

  • 1
  • 0
  • 约 60页
  • 2021-12-01 发布于安徽
  • 举报

软件设计课件:Lecture 04 Fundamentals of OOP Object and Class.ppt

软件设计课件:Lecture04FundamentalsofOOPObjectandClass.

* * * * * * * * * * * * * * * * * * * * * * * The initial military time is 00:00 The initial standard time is 12:00:00 AM ? Military time after setTime is 13:27 Standard time after setTime is 1:27:06 PM ? After attempting invalid settings: Military time: 00:00 Standard time: 12:00:00 AM Program Output * Outline The evolution way to the Object Oriented technique Abstract Data Type Class Scope and Accessing Class Members Separating Interface from Implementation Controlling Access to Members Access Functions and Utility Functions Scope Accessing Class Members Class scope Data members and member functions File scope Nonmember functions Function scope Variables defined in member functions, destroyed after function completes Inside a scope Members accessible by all member functions Referenced by name Scope Accessing Class Members function scope local scope file scope function scope local scope Outside a scope Use handles An object name, a reference to an object or a pointer to an object Accessing class members Same as structs Dot (.) for objects and arrow (-) for pointers Example: t.hour is the hour element of t TimePtr-hour is the hour element Scope Accessing Class Members Assign 7 to x and print using the objects name: 7 Assign 8 to x and print using a reference: 8 Assign 10 to x and print using a pointer: 10 Program Output * Outline The evolution way to the Object Oriented technique Abstract Data Type Class Scope and Accessing Class Members Separating Interface from Implementation Controlling Access to Members Access Functions and Utility Functions Separating Interface from Implementation Separating interface from implementation Easier to modify programs C++ programs can be split into Header files – contains class definitions and function prototypes Source-code files – contains member function definitions Program Outline: Using the same Time class as before, create a header file Create a source code file Load the header file to get the class

文档评论(0)

1亿VIP精品文档

相关文档