Answer to Question #274041 in C++ for manu

Question #274041

Write a program that would print the information (name, year of joining, salary, address) of three employees by creating a class named 'Employee'. The output should be as follows: Name Year of joining Address Robert 1994 64C- WallsStreat Sam 2000 68D- WallsStreat John 1999 26B- WallsStreat


1
Expert's answer
2021-12-04T04:24:05-0500
class Employee
{
private:
    string name;
    string idNumber;
    string department;
    string position;
    int worked;


public:
    Employee(string n, string idNum, string depart, string pos, int yrsWrkd)
    {
        name = n;
        idNumber = idNum;
        department = depart;
        position = pos;
        worked = yrsWrkd;
    }


    void setName(string n)
    {
        name = n;
    }
    void setId(string idNum)
    {
        idNumber = idNum;
    }
    void setDepartment(string depart)
    {
        department = depart;
    }
    void setPosition(string pos)
    {
        position = pos;
    }


    string const getName()
    {
        return name;
    }
    string const getID()
    {
        return idNumber;
    }
    string const getDepartment()
    {
        return department;
    }
    string const getPosition()
    {
        return position;
    }
    int const getYears()
    {
        return worked;
    }
};

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