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.