Kinh doanh - Marketing
Kinh tế quản lý
Biểu mẫu - Văn bản
Tài chính - Ngân hàng
Công nghệ thông tin
Tiếng anh ngoại ngữ
Kĩ thuật công nghệ
Khoa học tự nhiên
Khoa học xã hội
Văn hóa nghệ thuật
Sức khỏe - Y tế
Văn bản luật
Nông Lâm Ngư
Kỹ năng mềm
Luận văn - Báo cáo
Giải trí - Thư giãn
Tài liệu phổ thông
Văn mẫu
Giới thiệu
Đăng ký
Đăng nhập
Tìm
Danh mục
Kinh doanh - Marketing
Kinh tế quản lý
Biểu mẫu - Văn bản
Tài chính - Ngân hàng
Công nghệ thông tin
Tiếng anh ngoại ngữ
Kĩ thuật công nghệ
Khoa học tự nhiên
Khoa học xã hội
Văn hóa nghệ thuật
Y tế sức khỏe
Văn bản luật
Nông lâm ngư
Kĩ năng mềm
Luận văn - Báo cáo
Giải trí - Thư giãn
Tài liệu phổ thông
Văn mẫu
Thông tin
Điều khoản sử dụng
Quy định bảo mật
Quy chế hoạt động
Chính sách bản quyền
Giới thiệu
Đăng ký
Đăng nhập
0
Trang chủ
Công Nghệ Thông Tin
Kỹ thuật lập trình
Lecture note Data visualization - Chapter 14
Đang chuẩn bị liên kết để tải về tài liệu:
Lecture note Data visualization - Chapter 14
Lạc Phúc
90
26
pptx
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
This chapter presents the following content: Introduction to inheritance, inheritance in C++, IS-A relationship, polymorphism in inheritance, classes in inheritance, visibility rules, constructor and base class, adding members. | Lecture 14 Recap Introduction to Inheritance Inheritance in C++ IS-A Relationship Polymorphism in Inheritance Classes in Inheritance Visibility Rules Constructor and Base Class Adding Members Overriding a Method Methods can be override from the base class in the derived class by simply providing a derived class method with the same signature A derived class method must have the same or compatible return type Sometimes it is required to invoke the derived class method to the base class method to augment a base class method rather than doing something entirely different. This is known as partial overriding The scope operator can be used to call a base class method Example class Workaholic : public Worker { public : void dowork( ) { Worker::doWork( ); // Work like a Worker drinkCof fee ( ) ; // Take a break Worker::doWork( ); // Work like a Worker some more } }; Static and Dynamic Binding Example Code 1 Worker w; 2 Workaholic wh; 3 . . . 4 w. doWork ( ) ; wh. doWork ( ) ; The above code | Lecture 14 Recap Introduction to Inheritance Inheritance in C++ IS-A Relationship Polymorphism in Inheritance Classes in Inheritance Visibility Rules Constructor and Base Class Adding Members Overriding a Method Methods can be override from the base class in the derived class by simply providing a derived class method with the same signature A derived class method must have the same or compatible return type Sometimes it is required to invoke the derived class method to the base class method to augment a base class method rather than doing something entirely different. This is known as partial overriding The scope operator can be used to call a base class method Example class Workaholic : public Worker { public : void dowork( ) { Worker::doWork( ); // Work like a Worker drinkCof fee ( ) ; // Take a break Worker::doWork( ); // Work like a Worker some more } }; Static and Dynamic Binding Example Code 1 Worker w; 2 Workaholic wh; 3 . . . 4 w. doWork ( ) ; wh. doWork ( ) ; The above code illustrates the fact that we can declare Worker and Workaholic objects in the same scope because the compiler can deduce which dowork method to apply w is a Worker and wh is a Workahol ic, so the determination of which dowork is used in the two calls at line 4 is computable at compile time The decision made at compile time about which function to use to resolve an overload static binding/overloading Example 1 Worker *wptr; 2 cin >> x; 3 if (x != 0 ) 4 wptr =new Workaholic ( ); 5 else 6 wptr= new Worker ( ); 7 8 9 wptr -> doWork ( ); //which doWork is used Explanation of Example If x is zero, we create a Worker object; otherwise, we create a Workaholic object Recall that, as a Workaholic IS-A Worker, a Workaholic can be accessed by a pointer to a Worker Any method that we might call for Worker will have a meaning for Workaholic objects Public inheritance automatically defines a type conversion from a pointer to a derived class to a pointer to the base class We can declare that wptr
TÀI LIỆU LIÊN QUAN
Lecture note Data visualization - Chapter 1: Introduction to Data Visualization
Lecture note Data visualization - Chapter 1
Lecture note Data visualization - Chapter 2
Lecture note Data visualization - Chapter 3
Lecture note Data visualization - Chapter 4
Lecture note Data visualization - Chapter 5
Lecture note Data visualization - Chapter 6
Lecture note Data visualization - Chapter 7
Lecture note Data visualization - Chapter 8
Lecture note Data visualization - Chapter 9
crossorigin="anonymous">
Đã 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.