Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C++, Write a class EMPLOYEE with private data members NAME, SALARY. Use a con

ID: 3748782 • Letter: I

Question

In C++,

Write a class EMPLOYEE with private data members NAME, SALARY. Use a constructor to initialize NAME to "Thomas" and SALARY to 1000. Also write a class MANAGER that inherits from EMPLOYEE and has private data member DEPARTMENT. Declare an instance of each class and have the user enter values.

NOTE: PLEASE READ THE QUESTION CAREFULY AND ANSWER IT IN THE SIMPLIEST FORM. IF YOU'RE NOT SURE ABOUT WHAT YOU'RE DOING, PLEASE DO NOT ANSWER THE QUESTION. INCOMPLETE OR WRONG ANSWERS WILL GET NEGATIVE VOTES.

THANK YOU!

Explanation / Answer

#include<iostream>
#include<cstring>
using namespace std;
class Employee
{
    //variables
    private:
    char name[30];
    int salary;
  
    public:
    Employee()
    {
    strcpy(name,"Thomas");
    salary = 1000;
    }
  
    char* getName()
    {
        return name;
    }
    int getSalary()
    {
        return salary;
    }
  

};
class Manager : public Employee
{

private:
char department[30];
public:
Manager(char department[30])
    {
    strcpy(this->department,department);
  
    }
    char* getDepartment()
    {
        return department;
    }
    void display()
    {
    cout<<" Manager Name : "<<getName()<<" Salary : "<<getSalary()<<" Department : "<<getDepartment();
    }

};
int main()
{

  
   Manager m("Finance");
   m.display(); // call to method

    return 0;
}

Manager Name : Thomas Salary : 1000 Department : Finance

Do ask if any doubt. Please upvote.