Created
September 9, 2018 07:07
-
-
Save dibakarsutradhar/c9edaacd105bf4cfe2660b1b7a21a11f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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