I'm currently writing a class for a program and this is what I'm attempting to accomplish...
Setup: Sets
m_ptrEmployee
to NULL andm_beginHour
to hour.AssignEmployee: Sets
m_ptrEmployee
to employee.GetEmployeeName: Uses
m_ptrEmployee
andEmployee.GetName
to return the employees name. Returns “UNALLOCATED”, ifm_ptrEmployee
is NULL.Output: Uses
m_ptrEmployee
andEmployee.GetName
to displaym_beginHour
and the employee’s name something like this, “8:00 - David Johnson” or like this, “8:00 - UNALLOCATED”, ifm_ptrEmployee
is NULL.Reset: Resets
m_ptrEmployee
to NULL.GetIsSet: Returns true, if
m_ptrEmployee
is not NULL and false otherwise.
Here is my code...
#include <string>
using namespace std;
#include "Employee.h"
class Schedule
{
public:
void Setup( int hour )
{
m_ptrEmployee = NULL;
m_beginHour = hour;
};
void AssignEmployee( Employee* employee )
{
m_ptrEmployee = employee;
};
string GetEmployeeName()
{
if (m_ptrEmployee = NULL)
return "UNALLOCATED"
else
return Employee.GetName()
};
void Output()
{
if (m_ptrEmployee = NULL)
cout>> m_beginHour>>"--">>"UNALLOCATED">>endl;
else
cout>>m_beginHour>>"--">>GetName()>>endl;
}
void Reset()
{
m_ptrEmployee = NULL;
}
bool GetIsSet()
{
if (m_ptrEmployee != NULL)
return true;
else
return false;
}
private:
Employee* m_ptrEmployee;
int m_beginHour;
};
GetName()
is included in a previous class and it is...
public:
void Setup( const string& first, const string& last, float pay );
{
m_firstName = first;
m_lastName = last;
m_payPerHour = pay;
m_activeEmployee = true;
}
string GetName()
{
return m_firstName+""+m_lastName
};
I'm receiving multiple errors and I'm not sure what I'm doing wrong? This is my first time attempting to write classes with pointers, so I apologize if my code is absolutely awful.