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()), അധിക bonus-ഉം salary + bonus തിരികെ നൽകുന്ന payWithBonus()-ഉം ഉള്ള Manager : public Employee എന്നിവ എഴുതൂ. 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.