76 293
Assignments Done
Successfully Done
In May 2019

Answer to Question #31956 in C++ for Jay

Question #31956
Derive a class Programmer from Employee. Supply a constructor Programmer(string name, double salary) that calls the base-class constructor. Supply a function get_name that returns the name in the format “Hacker, Harry (Programmer)”.
Expert's answer
#ifndef CLASSES_H
#define CLASSES_H

#include <iostream>
#include <string>

using namespace std;

class Employee
string name;
double salary;

Employee(const string& name, double salary)
this->name = name;
this->salary = salary;

class Programmer : Employee
Programmer(string name, double salary) : Employee(name, salary) {}
string get_name()
return name + string(" (Programmer)");


int main()
Programmer p("Hacker, Harry", 9400);
cout << p.get_name();
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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions