程序问题

[复制链接]
1242|3
 楼主| txcy 发表于 2013-10-29 16:02 | 显示全部楼层 |阅读模式
ST, FIR, RS, AC, TE
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未定义,可我前面定义过了啊,这是怎么回事呢?
无冕之王 发表于 2013-10-29 16:24 | 显示全部楼层
首先你确定有没有包含下面两个头文件:
#include<deque>
#include<list>
然后确定你的while里面的 evendeq 有没打错。
pkat 发表于 2013-10-29 16:31 | 显示全部楼层
引用了头文件没有?
戈卫东 发表于 2013-10-29 19:14 | 显示全部楼层
evendep.push_back(*first);----------有没有拼写错误?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

274

主题

2106

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部