a1406964447
a1406964447
关注数: 1
粉丝数: 13
发帖数: 125
关注贴吧数: 5
求大神解答,为什么数据丢失了??通俗点,怕听不懂啊,谢谢 #include<iostream> #include<string> using namespace std; class CPerson{ public: CPerson(int a,char s,char *i,char *n):age(a),sex(s) { strcpy(name,n); strcpy(id,i); } void show() { cout<<"姓名="<<name<<"性别="<<sex<<"年龄="<<age; cout<<"身份证="<<id<<endl; } ~CPerson(){}; protected: int age;char sex;char id[19];char name[8]; }; class CEmployee:public CPerson{ private: char Department[20];double Salary; public: CEmployee(int a,char s,char *i,char *n,char *d,double S):CPerson(age,sex,id,name) { strcpy(Department,d); Salary=S; } void show2() { cout<<"姓名="<<name<<"性别="<<sex<<"年龄="<<age; cout<<"身份证="<<id<<endl; cout<<"部门="<<Department<<"薪水="<<Salary<<endl; } ~CEmployee() {}; }; void main() { char n[8]={"小明"}; char d[20]={"生活部"}; CEmployee c(22,'M',"513922199310151615",n,d,3000); c.show2(); }
大神求解,为什么会有数据丢失了? #include<iostream> #include<string> using namespace std; class CPerson{ public: CPerson(int a,char s,char *i,char *n):age(a),sex(s) { strcpy(name,n); strcpy(id,i); } void show() { cout<<"姓名="<<name<<"性别="<<sex<<"年龄="<<age; cout<<"身份证="<<id<<endl; } ~CPerson(){}; protected: int age;char sex;char id[19];char name[8]; }; class CEmployee:public CPerson{ private: char Department[20];double Salary; public: CEmployee(int a,char s,char *i,char *n,char *d,double S):CPerson(age,sex,id,name) { strcpy(Department,d); Salary=S; } void show2() { cout<<"姓名="<<name<<"性别="<<sex<<"年龄="<<age; cout<<"身份证="<<id<<endl; cout<<"部门="<<Department<<"薪水="<<Salary<<endl; } ~CEmployee() {}; }; void main() { char n[8]={"小明"}; char d[20]={"生活部"}; CEmployee c(22,'M',"513922199310151615",n,d,3000); c.show2(); }
1
下一页