【发布时间】:2013-10-01 19:14:27
【问题描述】:
我目前正在为一个程序编写一个类,这就是我想要完成的......
设置:将
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 - David Johnson”或类似“8:00 - 未分配”,如果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
};
我收到多个错误,但不确定自己做错了什么?这是我第一次尝试用指针编写类,所以如果我的代码非常糟糕,我深表歉意。
【问题讨论】:
-
您收到的错误是什么。请全部粘贴。
-
第一件事,有什么错误?总是显示错误,您可以复制和粘贴尽可能多的输出!总是!
标签: c++ class pointers return void