求助:帮我看看用链表实现集合的交并差的C++程序哪里有错
#include <iostream>#include <fstream>#include <list>using namespace std;template<typename T>void display(list<T> c2){list <T>::iterator c2_iter;c2_iter=c2.begin();while (c2_iter != c2.end()){cout <<" "<<*c2_iter;c2_iter++;}cout <<endl;}void jiao(list<int> a,list<int> b,list<int> c){list<int>::iterator ita=a.begin();list<int>::iterator itb=b.begin();do{do {if (*ita == *itb){c.push_back(*ita);itb++;ita++;}else{itb++;}} while (itb != b.end());}while(ita != a.end());}int main(){list<int> a;list<int> b;list<int> c;ifstream ain ("a.in");ifstream bin ("b.in");int at,bt;while(ain >>at){a.push_back(at);}while(bin >>bt){b.push_back(bt);}display(a);display(b);jiao(a,b,c);display(c);return 0;}
void jiao(list<int> a,list<int> b,list<int> &c) //注意是&c{ list<int>::iterator ita=a.begin(); list<int>::iterator itb; do { itb=b.begin(); do { if (*ita == *itb) { c.push_back(*ita); break; } else { itb++; } } while (itb != b.end()); ita++; }while(ita != a.end());}