How to i set the name of the employee? I dont understand how to use the string. The book only shows examples of integers. This is the assignment.
Write a class named Employee that has the following member variables:
• name. A string that holds the employee’s name.
• idNumber. An int variable that holds the employee’s ID number.
• department. A string that holds the name of the department where the employee works.
• position. A string that holds the employee’s job title.
The class should have the following constructors:
• A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee’s name, employee’s ID number, department, and position.
• A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee’s name and ID number. The department and position fields should be assigned an empty string (“ “);
• A default constructor that assigns empty strings (“ “) to the name, department, and position member variables, and 0 to the idNumber member variable.
This is my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#include "employee.h"
#include <iostream>
#include <string>
using namespace std;
//****************************************************
//constructor initliaizing everything to null *
//****************************************************
Employee::Employee()
{
name = "";
position = "";
department = "";
idNumber = 0;
}
//*********************************************
//setName sets member name *
//*********************************************
void setName
{
}
|