//ccc_empl.cpp //implementation file #include \"ccc_empl.h\" Employee::Employee(
ID: 3529351 • Letter: #
Question
//ccc_empl.cpp
//implementation file
#include "ccc_empl.h"
Employee::Employee() { salary = 0; }
Employee::Employee(string employee_name, double initial_salary) { name = employee_name; salary = initial_salary; }
void Employee::set_salary(double new_salary) { salary = new_salary; }
double Employee::get_salary() const
{ return salary; }
string Employee::get_name() const
{
return name; }
//ccc_empl.h
//header file
#ifndef CCC_EMPL_H
#define CCC_EMPL_H
#include using namespace std;
/** A basic employee class that is used in many examples in the book "Computing Concepts with C++ Essentials" */
class Employee { public:
/** Constructs an employee with empty name and no salary. */
Employee();
/** Constructs an employee with a given name and salary. @param employee_name the employee name @param initial_salary the initial salary */
Employee(string employee_name, double initial_salary);
/** Sets the salary of this employee. @param new_salary the new salary value */
void set_salary(double new_salary);
/** Gets the salary of this employee. @return the current salary */
double get_salary() const;
/** Gets the name of this employee. @return the employee name */
string get_name() const; private: string name; double salary;
}; #endif
Explanation / Answer
class Staff { public: ... private: vector members; }; Then use the Employee class that was previously created. Implement and test these methods: void add(const Employee& e) Employee find(const std::string& name) const void raise_salary(double percent) The find() method should allow you to find a specific employee by name. If the employee is not found, then return a default Employee object. while the raise_salary() method should raise the salaries for the entire staff by a percentage. (The percentage will be passed as 10 for 10%, so you'll need to divide by 100 when doing your calculation.) The add() method should add a new employee to the staff. So this is what i have so far... This is the Employee Class cpp code code: #include "ccc_empl.h" Employee::Employee() { salary = 0; } Employee::Employee(string employee_name, double initial_salary) { name = employee_name; salary = initial_salary; } void Employee::set_salary(double new_salary) { salary = new_salary; } double Employee::get_salary() const { return salary; } string Employee::get_name() const { return name; } This is the header for the above code: #ifndef CCC_EMPL_H #define CCC_EMPL_H #include using namespace std; class Employee { public: Employee(); Employee(string employee_name, double initial_salary); void set_salary(double new_salary); double get_salary() const; string get_name() const; private: string name; double salary; }; #endif This is my staff class header code: #ifndef P26_H #define P26_H #include #include "ccc_empl.h" // Define the Staff class here class Staff { public: Staff(); void add(const Employee& e); Employee find(const std::string& name) const; void raise_salary(double percent); private: vector members; }; #endif And this is the implementation i am trying to make it work =.= code: // Implement the Staff member functions here #include using namespace std; #include "p26.h" #include "ccc_empl.h" Staff::Staff() { } void Staff::add(const Employee& e) { members.push_back(e); } Employee Staff::find(const std::string& name) const { for (int i = 0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.