vector使用出错

Faceword 2015-01-31 11:10:13
Expression: vector iterator not incrementable
我用vector存指针,这些指针互相赋值了,释放内存时出现这个问题
vector<Sprite*> m_Spr;往m_Spr里存指针,然后程序结束时释放。中间我把:其中三个指针按游戏逻辑赋值给其中一个指针用来绘图,出现错误:
Debug Assertion Failed!

Program: C:\WINDOWS\SYSTEM32\MSVCP120D.dll
File: c:\program files (x86)\microsoft visual studio 12.0\vc\include\vector
Line: 101

Expression: vector iterator not incrementable

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)
线程 0x19c4 已退出,返回值为 3 (0x3)。
程序“[6304] Plane.exe”已退出,返回值为 3 (0x3)。
...全文
338 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
我不懂电脑 2015-02-02
  • 打赏
  • 举报
回复
使用std::auto_ptr 很方便智能
gzliudan 2015-02-01
  • 打赏
  • 举报
回复
不要存裸指针,应该改为shared_ptr
lother 2015-02-01
  • 打赏
  • 举报
回复
指针必须控制好释放顺序,2次释放就有问题!
draculamx 2015-01-31
  • 打赏
  • 举报
回复
贴些关键代码来看看吧。。。

1,221

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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