請進來看一下,不明白結果為啥不是預期的結果。

lpcjj1122 2009-09-03 12:57:00

#include <iostream>
#include <list>
#include <algorithm>
#include "print.h"
using namespace std;

class SimpleData
{
public:
int x;
int y;

SimpleData()
{
x = 0;
y = 0;
}
};


int main()
{
list<SimpleData> scoll;

for(int i = 0; i < 10; ++i)
{
SimpleData a;
a.x = i + 2;
a.y = i + 3;
scoll.push_back(a);
}

list<SimpleData>::const_iterator spos;
for(spos = scoll.begin(); spos != scoll.end(); ++spos)
cout << (*spos).x << ', ' << (*spos).y << endl;
}




輸出結果:
2112963
3112964
4112965
5112966
6112967
7112968
8112969
91129610
10129611
...


為什么是這結果??
...全文
39 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
fox000002 2009-09-03
  • 打赏
  • 举报
回复
把 ', ' 输出来了啊
lpcjj1122 2009-09-03
  • 打赏
  • 举报
回复
暈,曉得了。

7,540

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧