#include<iostream> #include<list> #include<cstring> using namespace std; class worker{ char name[10]; int age; double salary; public: worker(int a=0,char *p="noname",double c=0) { age=a; char *p1=new char[sizeof(p)+1]; strcpy(name,p1); } void setdata(char *name,int age,double wage); void display(); friend ostream& operator<<(ostream &os,worker &s); }; void worker::display() { cout<<name<<" "<<age<<" "<<salary; } ostream& operator<<(ostream &os,worker &s) { os<<s.age<<" "<<s.name[10]<<" "<<s.salary; return os; } int main() { worker a[6]; a[0]=worker (1,"a",3); a[1]=worker (4,"b",6); a[2]=worker (7,"c",9); a[3]=worker (1,"d",3); a[4]=worker (4,"e",6); a[5]=worker (7,"f",9); list<worker> l1,l2,l3; for(int i=0;i<3;i++) { l1.push_back(a[i]); } for(int j=3;j<6;j++) { l2.push_back(a[j]); } list<woker>::iterator iter; for(iter=l1.begin();iter!=l1.end();iter++) { cout<<*iter<<"\t"; } for(iter=l2.begin();iter!=l2.end();iter++) { cout<<*iter<<"\t"; } l1.merge(l2); for(iter=l1.begin();iter!=l1.end();iter++) { cout<<*iter<<"\t"; } return 0; }
报错跳到另一个文件的这一行
if (*__first2 < *__first1) { iterator __next = __first2; _M_transfer(__first1, __first2, ++__next); __first2 = __next; } else ++__first1; if (__first2 != __last2) _M_transfer(__last1, __first2, __last2); }
我也看不懂什么意思,求解
wDan_9527