Multiple Inheritance & Combining "Is-A" with "Has-A"
Focus: Multiple inheritance (class Derived : public Base1, public Base2), scope resolution for disambiguation, composition ("Has-A") inside an inheritance hierarchy ("Is-A"), and constructor execution sequencing.
Scenario & Requirements:
An academic department needs to model a senior faculty member who serves both as a lecturer (GiangVien) and an administrative manager (CanBoQuanLy), while being assigned an office room (PhongLamViec).
The program accepts data for a combined academic manager (GiangVienQuanLy) across three distinct sub-sections:
maGV (Lecturer ID): A non-empty string token or line (e.g., "GV001").luongGiangDay (Teaching Base Salary): A non-negative floating-point number (double >= 0.0).chucVu (Management Position): A string describing the title (e.g., "Head of Department", "Vice Dean").phuCapChucVu (Position Allowance): A non-negative floating-point number (double >= 0.0).soPhong (Office Room Number): A string token (e.g., "P1310", "Room 402").toaNha (Building Name): A string token (e.g., "Building A1").GiangVienQuanLy must inherit publicly from both GiangVien and CanBoQuanLy (class GiangVienQuanLy : public GiangVien, public CanBoQuanLy).GiangVienQuanLy must contain a private member object instance of PhongLamViec (PhongLamViec phong;).GiangVien, CanBoQuanLy, PhongLamViec, and GiangVienQuanLy) must be declared private.GiangVienQuanLy must use a member initializer list to pass parameters in explicit execution order:
GiangVien(id, teachingSalary)CanBoQuanLy(position, allowance)phong(room, building)GiangVienQuanLy must invoke base and component methods using scope resolution (GiangVien::xuat_gv(), CanBoQuanLy::xuat_ql(), and phong.xuat_phong()).<iomanip> stream manipulators (std::left, std::setw, std::fixed, std::setprecision(2)).Đang tải editor...