Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class AbstractEmployee
- {
- virtual void AskForPromotion()=0;
- };
- class Employee:AbstractEmployee
- {
- private:
- string Name;
- string Company;
- int Age;
- public:
- void setName(string name)
- {
- Name = name;
- }
- string getName()
- {
- return Name;
- }
- void setCompany(string company)
- {
- Company=company;
- }
- string getCompany()
- {
- return Company;
- }
- void setAge(int age)
- { if(age>=18)
- Age=age;
- }
- int getAge()
- {
- return Age;
- }
- void IntroduceYourself()
- {
- cout << "Name - " << Name << endl;
- cout << "Company - " << Company << endl;
- cout << "age - " << Age << endl;
- cout << endl;
- }
- Employee(string name, string company, int age)
- {
- Name = name;
- Company = company;
- Age = age;
- }
- void AskForPromotion()
- {
- if (Age > 30)
- cout << Name << " got promoted. " << endl;
- else
- cout << Name << " sorry, no promotion. " << endl;
- }
- };
- int main()
- {
- Employee employee1 = Employee("Emily","Amazon",26);
- Employee employee2 = Employee("Nick", "Microsoft", 49);
- employee1.AskForPromotion();
- employee2.AskForPromotion();
- }
Advertisement
Add Comment
Please, Sign In to add comment