我目前正在寫一類的節目,這就是我試圖完成......類錯誤與指針
設置:設置
m_ptrEmployee
爲NULL,m_beginHour
到小時。AssignEmployee:將
m_ptrEmployee
設置爲員工。GetEmployeeName:使用
m_ptrEmployee
和Employee.GetName
返回員工 名。如果m_ptrEmployee
爲NULL,則返回「UNALLOCATED」。輸出:利用
m_ptrEmployee
和Employee.GetName
顯示m_beginHour
和 員工的名字是這樣的,「8:00大衛 - 約翰遜」或類似這樣的,「8:00 - UNALLOCATED」,如果m_ptrEmployee
爲NULL。重置:將
m_ptrEmployee
重置爲NULL。GetIsSet:如果
m_ptrEmployee
不爲NULL,則返回true,否則返回false。
這裏是我的代碼...
#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()
包括在之前的類,它是...
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
};
我收到多個錯誤和我米不知道我做錯了什麼?這是我第一次嘗試用指針編寫類,所以我很抱歉如果我的代碼是絕對可怕的。
您收到了哪些錯誤。請將它們全部粘貼。 – 2013-09-26 01:14:37
首先,錯誤是什麼?總是顯示錯誤,您可以隨意複製和粘貼儘可能多的輸出!總是! –