Skip to content

Instantly share code, notes, and snippets.

@dibakarsutradhar
Created September 9, 2018 07:07
Show Gist options
  • Select an option

  • Save dibakarsutradhar/c9edaacd105bf4cfe2660b1b7a21a11f to your computer and use it in GitHub Desktop.

Select an option

Save dibakarsutradhar/c9edaacd105bf4cfe2660b1b7a21a11f to your computer and use it in GitHub Desktop.
class Employee {
public:
virtual void raiseSalary() {
// some codes goes here
}
virtual void promote() {
// some codes goes here
}
};
class Manager : public Employee {
virtual void raiseSalary() {
// Manage's specific raise salary law, salary increment may differ from other workers
}
virtual void promote() {
// Manager's specific promote
}
};
// ম্যানেজারের মতোণ এরকম অনেক কর্মচারী থাকতে পারে
// যাদের সেলারী বাড়ানো জন্য আলাদা সিম্পল রুলস থাকতে পারে
// এখানে emp[] হচ্ছে পয়েন্টার দের একটি অ্যারে।
void globalRaiseSalary(Employee *emp[], int n) {
for (int i = 0; i < n; i++)
emp[i] -> raiseSalary(); // Polymorphic Call: Calls raiseSalary()
// According to the actual object, not according to the type of pointer
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment