Answer to Question #192447 in C++ for Dunga

Question #192447

Write a C++ program to read and print employee information as shown below using hierarchical inheritance.your base class (basicinfo) must show basic information of name employee, ID and gender. Create another base classdeptInfo which captures department information like department name, assigned work and time to complete the workin hours, create the last base class which handles loan information like loan details and loan amount.


Enter Name: Mickey

Enter Emp. Id: 1121

Enter Gender: F

Enter Department Name: Testing

Enter assigned work: To test login form

Enter time in hours to complete work: 20

Employee's Information is: 

Basic Information...:

Name: Mickey

Employee ID: 1121

Gender: F


1
Expert's answer
2021-05-12T14:56:38-0400
#include <iostream>
#include <string>
using namespace std;
class Basicinfo{
    protected:
        string name;
        int id;
        char gender;
    public:
        Basicinfo(){}
};
class ClassdeptInfo{
    protected:
        string deptname, assignedwork;
        int time;
    public:
        ClassdeptInfo(){}
};
class Loan{
    protected:
        string details;
        int amount;
    public:
        Loan(){}
};
class Employee:public Basicinfo, public ClassdeptInfo, public Loan{
    public:
        Employee(){}
        void getdetails(){
            cout<<"\nEnter name: "; cin>>name;
            cout<<"Enter Emp. ID: "; cin>>id;
            cout<<"Enter gender: "; cin>>gender;
            cout<<"Enter department name: "; cin>>deptname;
            cout<<"Enter assgned work: "; cin>>assignedwork;
            cout<<"Enter time in hours to complete work: "; cin>>time;
        }
        void putdetails(){
            cout<<"\nEmployee information is...:";
            cout<<"\nName: "<<name;
            cout<<"\nEmployee ID: "<<id;
            cout<<"\nGender: "<<gender;
        }
};
int main(){
    Employee A;
    A.getdetails();
    A.putdetails();
    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