int main()
{
int a [5] = {1,2,3,4,5};
list<int> ilist(a,a+5);
deque<int> odddeq;
deque<int> evendeq;
list<int>::const_iterator first = ilist.begin(),last = ilist.end();
while(first != last)
{
if(*first%2 == 0)
evendep.push_back(*first);
else
odddeq.push_back(*first);
++first;
}
for(deque<int>::const_iterator it1 = odddeq.begin();it1 != odddeq.end();++it1)
cout<<*it1<<" ";
cout<<endl;
for(deque<int>::const_iterator it2 = evendeq.begin();it2 != evendeq.end();++it2)
cout<<*it2<<" ";
cout<<endl;
return 0;
}
编了这样一段程序,可是编译时出错,说在while里evendeq未定义,可我前面定义过了啊,这是怎么回事呢? |