Answer to Question #288822 in C++ for Abdullah Khan

Question #288822

Provide the C++ implementation of the following.


               The Person class has name and age as its attributes. It has an overloaded constructor to initialize the values and appropriate accessor and mutator methods. The Employee class has name of the employer and wage as its attributes with an overloaded constructor and appropriate accessor and mutator methods.



1
Expert's answer
2022-01-19T10:35:39-0500
#include <iostream>
using namespace std;
class Person{
    string name;
    int age;
    public:
        Person(string _name, int _age) : name(_name), age(_age) {}
        string getName() const {
            return name;
        }
        int getAge() const {
            return age;
        }
        void setName(string _name){
            name = _name;
        }
        void setAge(int _age){
            age = _age;
        }
};


class Employee{
    string name;
    float wage;
    public:
        Employee(string _name, float _wage) : name(_name), wage(_wage) {}
        string getName() const {
            return name;
        }
        float getAge() const {
            return wage;
        }
        void setName(string _name){
            name = _name;
        }
        void setAge(float _wage){
            wage = _wage;
        }
};

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