tailieunhanh - Object oriented programming with C++ - Session 6 Multiple Inheritance and Polymorphism
Describe Multiple Inheritance Constructors under Multiple Inheritance Ambiguity in Multiple Inheritance Multiple Inheritance with a Common Base Describe Virtual Base Classes Constructors and Destructors Use Pointers to Objects to access Member Functions | Multiple Inheritance and Polymorphism Session 6 Session Objectives Describe Multiple Inheritance Constructors under Multiple Inheritance Ambiguity in Multiple Inheritance Multiple Inheritance with a Common Base Describe Virtual Base Classes Constructors and Destructors Use Pointers to Objects to access Member Functions Object Oriented Programming with C++ / Session 6 / of 44 Session Objectives(Contd.) Describe Virtual functions Describe Polymorphism Describe Dynamic binding Describe Pure Virtual Functions Describe Abstract classes Describe Virtual destructors Object Oriented Programming with C++ / Session 6 / of 44 Multiple Inheritance Multiple inheritance is the process of creating a new class from more than one base class. The derived class inherits the properties of two or more base classes. Multiple inheritance can combine the behaviour of many base classes in a single class. A multiple inheritance hierarchy represents a combination of its base classes. Object Oriented | Multiple Inheritance and Polymorphism Session 6 Session Objectives Describe Multiple Inheritance Constructors under Multiple Inheritance Ambiguity in Multiple Inheritance Multiple Inheritance with a Common Base Describe Virtual Base Classes Constructors and Destructors Use Pointers to Objects to access Member Functions Object Oriented Programming with C++ / Session 6 / of 44 Session Objectives(Contd.) Describe Virtual functions Describe Polymorphism Describe Dynamic binding Describe Pure Virtual Functions Describe Abstract classes Describe Virtual destructors Object Oriented Programming with C++ / Session 6 / of 44 Multiple Inheritance Multiple inheritance is the process of creating a new class from more than one base class. The derived class inherits the properties of two or more base classes. Multiple inheritance can combine the behaviour of many base classes in a single class. A multiple inheritance hierarchy represents a combination of its base classes. Object Oriented Programming with C++ / Session 6 / of 44 Multiple Inheritance (Contd.) Student Teacher Teaching assistant Base class Base class Derived class Object Oriented Programming with C++ / Session 6 / of 44 Multiple Inheritance (Contd.) The syntax for multiple inheritance is similar to that for single inheritance. class Teacher { }; class Student { }; class Teach_asst: public Teacher, public Student The names of both the base classes are provided separated by a comma. The rules of inheritance and access for multiple inheritance are the same as for single inheritance. Object Oriented Programming with C++ / Session 6 / of 44 Constructors class Teacher{ private: int x; public: Teacher(){x =0;} //constructors Teacher(int s){x = s;} }; class Student{ private: int y; public: Student(){y = 0;} //constructor Student(int a){y = a;} }; Object Oriented Programming with C++ / Session 6 / of 44 Constructors (Contd.) class Teach_asst: public Teacher,public Student { private: int z; public: .
đang nạp các trang xem trước