|
<p>有一处错误是:'employer::employer' : constructors not allowed a return type</p><p>那位大虾帮忙看一下:</p><p>源代码如下:</p><p>#include<iostream><br/>#include<cmath><br/>using namespace std;<br/>class employee<br/>{<br/> public:<br/> employee();<br/> ~employee();<br/> employee(employee &e);<br/> void Add();<br/> void Show();<br/> private:<br/> int No;<br/> char sex;<br/> float birth;<br/> float idNo;<br/>};<br/>employee::employee(employee &e)<br/>{ <br/> No=e.No;<br/> sex=e.sex;<br/> birth=e.birth;<br/> idNo=e.idNo;<br/> cout<<"employee拷贝数据被调用"<<endl;<br/>}<br/>class employer<br/>{<br/> public:<br/> employer(employee xe1,employee xe2);<br/> employer(employer &);<br/> private:<br/> employee e1,e2;<br/>}<br/>employer::employer(employee xe1,employee xe2)<br/>:e1(xe1),e2(xe2)<br/>{ <br/> cout<<"employer构造函数被调用 "<<endl;<br/> e1.Add();<br/> e1.Show();<br/>}<br/>employer::employer(employer &em):e1(em.e1),e2(em.e2)<br/>{<br/> cout<<"employer拷贝构造函数被调用"<<endl;<br/>}<br/>inline void employee::Add()<br/>{<br/> cout<<"输入增加的职工信息"<<endl;<br/> cin>>No>>sex>>birth>>idNo;<br/>}<br/>inline void employee::Show()<br/>{<br/> cout<<"职工号:"<<No<<"性别:"<<sex<<"出生日期:"<<birth<<"身份证号:"<<idNo;<br/>}<br/> void main()<br/>{<br/> employee e1,e2;<br/> e1.Add();<br/> e1.Show();<br/> getchar();<br/>}<br/></p> |
|