Windows API 的 STL 成员变量初始化问题
我正在创建一个 Windows 应用程序,它使用刺向量作为成员变量。由于某种原因,我可以编译,但是当它尝试获取任何向量成员时就会崩溃。错误为 0xC0000005:读取位置 0xcdcdcdd9 时发生访问冲突。在向量类的成员函数中。
这是 size() 函数崩溃的地方。
size_type capacity() const
{ // return current length of allocated storage
return (this->_Myend - this->_Myfirst);
}
我正在使用 Visual Studio 2010。
谢谢 姜戈
I am creating a windows app that uses a vector of stings as a member variable. For some reason, I can compile but when it tries to get at any of the vectors members is crashes. the error is 0xC0000005: Access violation reading location 0xcdcdcdd9. in the member function of the vector class.
this is the size() function where it breaks.
size_type capacity() const
{ // return current length of allocated storage
return (this->_Myend - this->_Myfirst);
}
I am using visual studios 2010.
thank you
Django
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题不在于 STL 代码,而在于您的代码。
由于您没有粘贴代码,我将向您展示一个应该如何使用字符串向量的示例。
The problem is not with the STL code but with your code.
Since you didn't paste your code I'll show you an example of how you should be using a vector of strings.
我以前也遇到过这样的事情。最可能的原因是堆损坏。
I've come across this kind of thing before. Most likely cause is a corrupt heap.
在标题中。
在 cpp 中,
抱歉缺少代码......我在想什么(手掌)
in the header.
in the cpp
sorry about the lack of code.... what wa I thinking (face palm)