Lesson 17 of 24

Inheritance

10 min 35 XP

class Car : public Vehicle से Car को Vehicle के public और protected members मिलते हैं। Derived constructor अपनी initializer list में base constructor को call करता है। C++ multiple inheritance भी support करता है।

Example: edit me and press Run

Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.

Challenge

+35 XP

Base class Employee (name, salary, salary लौटाने वाला double pay()) और Manager : public Employee लिखें जिसमें अतिरिक्त bonus और salary + bonus लौटाने वाला payWithBonus() हो। main() में name, salary और bonus पढ़ें और print करें: Input: Ravi 50000 7500 Output: Ravi base pay: 50000 Ravi total pay: 57500

Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.