c++中关于类中类,继承与派生问题 报错为 error C2504: 'employee' : base class undefined

程序为#include<iostream>usingnamespacestd;#include<string.h>classemployee{protected:char... 程序为
#include<iostream>
using namespace std;
#include<string.h>

class employee
{
protected:
char number[50];
char name[30];
char sexity[10];
char position[30];
double wage;
class Date
{
private:
int year;
int month;
int day;
public:
void SetYear(int year)
{
this->year=year;
}
void SetMonth(int month)
{
this->month=month;
}
void SetDay(int day)
{
this->day=day;
}
int GetYear()
{
return year;
}
int GetMonth()
{
return month;
}
int GetDay()
{
return day;
}
};
public:
employee(char* number,char* name,char* sexity,char* position,int year,int month,int day)
{
strcpy(this->number,number);
strcpy(this->name,name);
strcpy(this->sexity,sexity);
strcpy(this->position,position);
Date::SetYear(year);
Date::SetMonth(month);
Date::SetDay(day);
}
employee()
{
number=0;
name=jiangwei;
sexity=male;
position=employee;
wage=1500;
Date::year=1994;
Date::month=7;
Date::day=28;
}
employee(char* number=0,char* name="jiangwei",char* sexity="male",char* position="employee",int year=1994,int month=7,int day=28,double wage=0)
{
strcpy(this->number,number);
strcpy(this->name,name);
strcpy(this->sexity,sexity);
strcpy(this->position,position);
Date::SetYear(year);
Date::SetMonth(month);
Date::SetDay(day);
};

class technician : public employee
{
protected:
double worktime;
public:
technician(char* number,char* name,char* sexity,char* position,double worktime,int year,int month,int day) : employee(number,name,sexity,position,Date::year,Date::month,Date::day)
{
this->worktime=worktime;
}
void display()
{
wage=25*worktime;
cout<<"wage:"<<wage<<endl;
}
};

void main()
{
technian p1("123456","weng","male","director",8,1994,7,28);
p1.show();
}

完整报错为
error C2504: 'employee' : base class undefined
fatal error C1004: unexpected end of file found
展开
 我来答
_ahappyboy
2013-04-24 · TA获得超过190个赞
知道小有建树答主
回答量:152
采纳率:0%
帮助的人:110万
展开全部
#include<iostream>
using namespace std;
#include<string.h>
class employee
{
protected:
char number[50];
char name[30];
char sexity[10];
char position[30];
double wage;
class Date
{
private:
static int year;
static int month;
static int day;
public:
Date() {}
static void SetYear(int _year)
{
year= _year;
}
static void SetMonth(int _month)
{
month = _month;
}
static void SetDay(int _day)
{
day = _day;
}
static int GetYear()
{
return year;
}
static int GetMonth()
{
return month;
}
static int GetDay()
{
return day;
}
};
public:
employee(char* number,char* name,char* sexity,char* position,int year,int month,int day)
{
strcpy(this->number,number);
strcpy(this->name,name);
strcpy(this->sexity,sexity);
strcpy(this->position,position);
Date::SetYear(year);
Date::SetMonth(month);
Date::SetDay(day);
}
employee(char* number="0",char* name="jiangwei",char* sexity="male",char* position="employee",int year=1994,int month=7,int day=28,double wage=0)
{
//number = new char[x]; ;
strcpy(this->number,number);
strcpy(this->name,name);
strcpy(this->sexity,sexity);
strcpy(this->position,position);
Date::SetYear(year);
Date::SetMonth(month);
Date::SetDay(day);
}
};
int employee::Date::year = 0;
int employee::Date::month = 0;
int employee::Date::day = 0;
class technician : public employee
{
protected:
double worktime;
public:
technician(char* number,char* name,char* sexity,char* position,double worktime,int year,int month,int day)
{
this->worktime=worktime;
}
void display()
{
wage=25*worktime;
cout<<"wage:"<<wage<<endl;
}
};
void main()
{
technician p1("123456","weng","male","director",8,1994,7,28);
p1.display();
}

仅供参考,继续交流!

千江月success
2013-04-22 · TA获得超过827个赞
知道小有建树答主
回答量:1031
采纳率:100%
帮助的人:911万
展开全部
#include<iostream>
using namespace std;
#include<string.h>
class Date
{
private:
static int year;
static int month;
static int day;
public:
static void SetYear(int _year)
{
year=_year;
}
static void SetMonth(int _month)
{
month=_month;
}
static void SetDay(int _day)
{
day=_day;
}
static int GetYear()
{
return year;
}
static int GetMonth()
{
return month;
}
static int GetDay()
{
return day;
}
};
int Date::year = 0;
int Date::month = 0;
int Date::day = 0;
class employee
{
protected:
char number[50];
char name[30];
char sexity[10];
char position[30];
double wage;
public:
employee(char* number=0,char* name="jiangwei",char* sexity="male",char* position="employee",int year=1994,int month=7,int day=28,double wage=0)
{
strcpy(this->number,number);
strcpy(this->name,name);
strcpy(this->sexity,sexity);
strcpy(this->position,position);
Date::SetYear(year);
Date::SetMonth(month);
Date::SetDay(day);
}
};
class technician : public employee
{
protected:
double worktime;
public:
technician(char* number,char* name,char* sexity,char* position,double worktime,int year,int month,int day) : employee(number,name,sexity,position,Date::GetYear(),Date::GetMonth(),Date::GetDay())
{
this->worktime=worktime;
}
void display()
{
wage=25*worktime;
cout<<"wage:"<<wage<<endl;
}
};
void main()
{
technician p1("123456","weng","male","director",8,1994,7,28);
p1.display();
}

----------------------------------------

只能说类设计得一塌糊涂,虽然我也好不了多少(1年前)。。

已赞过 已踩过<
你对这个回答的评价是?
评论 收起
gtj42398
2013-06-16
知道答主
回答量:43
采纳率:0%
帮助的人:18万
展开全部
类雇员没有看到吗?

你这样做类? ?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式