In: Computer Science
Task use c++ and Create Base class task with virtual method Create a pair of derivative classes of architecture, scientist, economist - Define a salary in each of these classes and create a method that prints the salary for each job Create a working object Use dynamic_cast Use typeid Create an object for each job that it will include the number of employees of that type and the method of printing these numbers
I have implemented the Employee,Architect,Economist and Scientist classes and main function per the given description.
Please find the following Code Screenshot, Output, and Code.
ANY CLARIFICATIONS REQUIRED LEAVE A COMMENT
1.CODE SCREENSHOT :


2.OUTPUT :

3.CODE :
#include<iostream>
using namespace std;
/*Create a base class EMployee with pure virtual method*/
 class Employee {
         public :
         virtual void printSalary()=0;
};
/*Architect deived class from Employee that implement the virtual method.*/
class Architect : public  Employee{
        private:
        double salary;
        public :
         Architect(double d){
                 salary=d;
         }
         void printSalary(){
                cout<<"Architect Salary "<<salary<<endl;
         }
};
/*Scientist deived class from Employee that implement the virtual method.*/
class Scientist : public  Employee{
        private:
        double salary;
        public :
          Scientist(double d){
                 salary=d;
         }
         void printSalary(){
                cout<<"Scientist Salary "<<salary<<endl;
         }
};
/*Economist deived class from Employee that implement the virtual method.*/
class Economist : public Employee{
        private:
        double salary;
        public :
        Economist (double d){
                
                 salary=d;
         }
         void printSalary(){
                cout<<"Economist Salary "<<salary<<endl;
         }
};
int main(){
        /*Create working objects of each class and use dynamic_cast*/ 
        Employee *t=  new Economist(20000);
        Economist *e=dynamic_cast<Economist*>(t);
        e->printSalary();
        t=  new Scientist(10000);
        Scientist *s=dynamic_cast<Scientist*>(t);
        s->printSalary();
        t=  new Architect(30000);
        Architect *a=dynamic_cast<Architect*>(t);
        a->printSalary();
}