Chapter 6 - Classes and Data Abstraction

Data abstraction refers to, providing only essential information to the outside word and hiding their background details ie. to represent the needed information in program without presenting the details. Data abstraction is a programming (and design) technique that relies on the separation of interface and implementation. | Chapter 6: Classes and Data Abstraction Outline Introduction Structure Definitions Accessing Structure Members Implementing a User-Defined Type Time with a struct Implementing a Time Abstract Data Type with a class Class Scope and Accessing Class Members Separating Interface from Implementation Controlling Access to Members Access Functions and Utility Functions Initializing Class Objects: Constructors Using Default Arguments with Constructors Destructors When Constructors and Destructors Are Called Using Set and Get Functions Subtle Trap: Returning a Reference to a private Data Member Default Memberwise Assignment Software Reusability Introduction Object-oriented programming (OOP) Encapsulates data (attributes) and functions (behavior) into packages called classes Information hiding Class objects communicate across well-defined interfaces Implementation details hidden within classes themselves . | Chapter 6: Classes and Data Abstraction Outline Introduction Structure Definitions Accessing Structure Members Implementing a User-Defined Type Time with a struct Implementing a Time Abstract Data Type with a class Class Scope and Accessing Class Members Separating Interface from Implementation Controlling Access to Members Access Functions and Utility Functions Initializing Class Objects: Constructors Using Default Arguments with Constructors Destructors When Constructors and Destructors Are Called Using Set and Get Functions Subtle Trap: Returning a Reference to a private Data Member Default Memberwise Assignment Software Reusability Introduction Object-oriented programming (OOP) Encapsulates data (attributes) and functions (behavior) into packages called classes Information hiding Class objects communicate across well-defined interfaces Implementation details hidden within classes themselves User-defined (programmer-defined) types: classes Data (data members) Functions (member functions or methods) Similar to blueprints – reusable Class instance: object Structure Definitions Structures Aggregate data types built using elements of other types struct Time { int hour; int minute; int second; }; Structure member naming In same struct: must have unique names In different structs: can share name struct definition must end with semicolon Structure tag Structure members Structure Definitions Self-referential structure Structure member cannot be instance of enclosing struct Structure member can be pointer to instance of enclosing struct (self-referential structure) Used for linked lists, queues, stacks and trees struct definition Creates new data type used to declare variables Structure variables declared like variables of other types Examples: Time timeObject; Time timeArray[ 10 ]; Time *timePtr; Time &timeRef = timeObject; Accessing Structure Members Member .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
12    20    1    24-11-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.