Answer to Question #206569 in C++ for laiba

Question #206569

 write a class employee that contains attributes of employee id and his scale.the class contains member functions to input and show <b><i>the</i></b> attribute.Write a child class manager that inherits Employee class.The child class has attributes of manager id and his department. It also contains the member functions to input and show its <b><i>attributes</i></b>


1
Expert's answer
2021-06-13T10:23:56-0400



#include <iostream>


using namespace std;
class Employee{
    protected:
        int employee_id;
        double scale;
    public:
        void input(){
            cout<<"\nEnter employee id:";
            cin>>employee_id;
            cout<<"\nEnter employee scale:";
            cin>>scale;
        }
        void show(){
            cout<<"\nEmployee ID:"<<employee_id<<endl;
            cout<<"\nEmployee scale:"<<scale<<endl;
        }
};
class Manager:public Employee{
    private:
        int manager_id;
        string dept;
    public:
        void input(){
            cout<<"\nEnter manager id: ";
            cin>>manager_id;
            cout<<"\nEnter manager department: ";
            cin>>dept;
        }
        void show(){
            cout<<"\nManager ID:"<<manager_id<<endl;
            cout<<"\nManager department:"<<dept<<endl;
        }
};
int main()
{
    Employee e;
    e.input();
    e.show();
    Manager m;
    m.input();
    m.show();


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog