关闭

[置顶] 帮忙啊:c++ 用链表实现一类

258人阅读 评论(0) 收藏 举报

老改不出,不知问题在哪里,请大伙帮忙看看,谢谢拉 ,代码如下: #ifndef EMPLOYEE_H #define EMPLOYEE_H #include using namespace std; class Employee { protected: long number; string name; public: Employee() { number = 001; name = "null"; } Employee(long mnumber,string mname); void setNumber(long mnumber); void setName(string mname); long getNumber(); string getName(); void showEmployeeInfo(); }; #endif #include "Employee.h" #include #include #include using namespace std; Employee::Employee(long mnumber,string mname) { number = mnumber; name = mname; void Employee::setNumber(long mnumber) { number = mnumber; } void Employee::setName(string mname) { name =mname; } long Employee::getNumber() { return number; } string Employee::getName() { return name; } void Employee::showEmployeeInfo() { cout<<"编号为:"<next = NULL; } void EmployeeList::insert(Employee &emp) { LinkList p= new Node(); p->number = emp.getNumber(); p->name = emp.getName(); p->next = tou->next; tou->next = p; } void EmployeeList::showEmployeeList() { LinkList p; p = tou; while ((p->next)++ != NULL) p->showEmployeeInfo(); } //主函数 #include "EmployeeList.h" #include "Employee.h" #include #include #include #include using namespace std; int main(){ Employee zhang(001,'M',"fafa2121",21); Employee fa(002,'M',"zhuzhu",22); EmployeeList e1; e1.insert(zhang); //e1.insert(fa); e1.showEmployeeList(); return 0; }

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:494次
    • 积分:14
    • 等级:
    • 排名:千里之外
    • 原创:1篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章存档