Lecture Object oriented programming - Lecture no 16

After studying this chapter you will be able to: Describe how objects are returned from methods, describe how the reserved word this is used, define overloaded methods and constructors, define class methods and variables, describe how the arguments are passed to the parameters using the pass-by-value scheme, document classes with javadoc comments, organize classes into a package. | CSC241: Object Oriented Programming Lecture No 16 Previous lecture Abstract class Public and private Inheritance Difference come when creating objects of derived class Level of inheritance Object of class C can access public member of class B and A class A { }; class B : public A { }; class C : public B { }; Today’s Lecture Multiple inheritance Example program: employ and student class Constructor in multiple inheritance Example program Aggregation Composition Multiple inheritance A class can be derived from more than one base class. This is called multiple inheritance class A { }; class B { }; class C : public A, public B{ }; Cont. Suppose we need to record the educational experience of some of the employees in the EMPLOY program In a different project, we’ve already developed a class called student that models students with different educational backgrounds Instead of modifying the employee class to incorporate educational data, we will add this data by multiple inheritance from the | CSC241: Object Oriented Programming Lecture No 16 Previous lecture Abstract class Public and private Inheritance Difference come when creating objects of derived class Level of inheritance Object of class C can access public member of class B and A class A { }; class B : public A { }; class C : public B { }; Today’s Lecture Multiple inheritance Example program: employ and student class Constructor in multiple inheritance Example program Aggregation Composition Multiple inheritance A class can be derived from more than one base class. This is called multiple inheritance class A { }; class B { }; class C : public A, public B{ }; Cont. Suppose we need to record the educational experience of some of the employees in the EMPLOY program In a different project, we’ve already developed a class called student that models students with different educational backgrounds Instead of modifying the employee class to incorporate educational data, we will add this data by multiple inheritance from the student class The student class stores the name of the school or university last attended and the highest degree received Educational information is not relevant to every class of employee Miniprogram showing relationships class student { }; class employee { }; class manager : private employee, private student { }; class scientist : private employee, private student { }; class laborer : public employee { }; const int LEN = 80; class employee{ private: char name[LEN]; unsigned long number; public: void getdata(){ cout > name; cout > number; } void putdata() const { cout > school; cout > degree; } void putedu() const { cout << “School: “ << school; cout << “Degree earned: “ << degree; } }; class .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.