OOP Microproject
OOP Microproject
Example Structure
1. Base Class: Employee - holds basic details.
2. Derived Class: SalariedEmployee - calculates salary deductions.
Required Inputs
User Inputs
Employee ID
Employee Name
Basic Salary
Leaves Taken in Month
Code Snippet - Class Definition (Employee)
class Employee {
protected:
int employeeID;
string employeeName;
float basicSalary;
int leaveTaken;
public:
Employee(int id, const string& name, float salary, int leave)
: employeeID(id), employeeName(name), basicSalary(salary), leaveTaken(leave) {}
virtual float calculateNetSalary() const = 0; // Pure virtual function
virtual void display() const {
cout << "Employee ID: " << employeeID << "\n"
<< "Employee Name: " << employeeName << "\n"
<< "Basic Salary: " << basicSalary << "\n"
<< "Leaves Taken: " << leaveTaken << endl;
}
virtual ~Employee() {} // Virtual destructor
};
Code Snippet - Class Definition (Salaried Employee)
return 0;
}
Conclusion
Benefits
Clear structure and reusability with inheritance.
Easy to extend and manage employee information.
Thank You !