Inheritance
Inheritance
Inheritance
What is Inheritance?
How is it used?
Design a system for employees in a company. The system should have a base class Employee
with common attributes like name and salary. There are specific types of employees:
Coding
using System;
Console.WriteLine();
// Create a Part-Time Employee
PartTimeEmployee partTimeEmp = new PartTimeEmployee("Bob", 1000, 20, 25);
Console.WriteLine("Part-Time Employee Details:");
partTimeEmp.DisplayDetails();
}
}
Output
Hours Worked: 20
Virtual keyword