Pages

Monday, July 28, 2025

Runtime Polymorphism – Employee and Manager : Salary Based Problem.

 #include <iostream>
using namespace std;

class Employee {
public:
virtual void computeSalary() {
cout << "Employee salary: 500rs" << endl; 
}
};


class Manager : public Employee {
public:
void computeSalary() override {
cout << "Manager Salary: 1500rs" << endl; } };

int main() {
Employee* = emp;
Manager mgr;
emp  = &mgr;

emp->computeSalary(); // Calls Manager's version...

return 0;

}


No comments:

Post a Comment

how to become red on codeforces by Errichto Algorithms | explained simply in a blog

 Yes. I found an available transcript of the video and summarized it simply. The video is “How To Become Red Coder? (codeforces.com)” by Err...