将项pushing_back到矢量中包含的矢量时未处理的异常
Unhandled exception when pushing_back an item to a vector contained in a vector
当我尝试迭代包含另一个向量的向量时,我发现一些困难。我有一个头文件,它定义了这样的结构: typedef struct Set{ 查尔·瓦纳姆[32]; 无效 * 值; } 设置;
typedef struct Setup {
float instant;
std::vector<Set *> SetVar;
} Setup;
std::vector<Setup *> TestCase;
在 cpp 中,我有一个函数,它只是读取一个 xml 文件并将 readen 值解析为 TestCase 向量,如下所示:
while(SetupHandle.ToElement()){
Setup * newSetup = (Setup *)malloc(sizeof(Setup));
str = SetupHandle.ToElement()->Attribute("instant");
newSetup->instant = atof(str);
TiXmlHandle SetHandle = SetupHandle.FirstChild("Set");
i=0;
while(SetHandle.ToElement()){
Set * newSet = (Set *)malloc(sizeof(Set));
str = SetHandle.ToElement()->Attribute("Variable");
strcpy(newSet->varname, str);
const char * newstr = SetHandle.ToElement()->Attribute("Value");
newSet->value = (void *) newstr;
newSetup->SetVar.push_back(newSet);
i++;
SetHandle = SetupHandle.Child("Set", i);
}
TestCase.push_back(newSetup);
index++;
SetupHandle = TC_top.Child("Setup", index);
}
该库可以编译,但是当我使用它时,程序在显示"newSetup->SetVar.push_back(newSet);"的行中崩溃。它抛出一个未经处理的异常,指出:"ISORC2014_CaseStudy_d.exe:0xC0000005:访问冲突读取位置0xcdcdcdc1中0x0430d7ba (tcmodule_psttm_isorc2014_d.pyd) 处未处理的异常。
有人知道我做错了什么吗?
您似乎试图通过使用malloc()
来智胜系统。请放心,系统会回复您的!如果你不使用new
这些物体就不会自动构建,你会遭受各种悲伤。在C++,基本上没有malloc()
的位置!C 内存函数有时用作内存分配工具的一部分,也可能用作连接遗留代码时,但在任何情况下都不足以malloc()
C++对象。
相关文章:
- 在c++中实现LinkedList时,应出现未处理的错误
- 如何修复链表类实现的未处理异常0xDDDDDDDD
- 在信号处理程序中捕获C++未处理的异常并恢复应用程序
- 在C++程序中使用的迭代器中未处理的异常
- 在 ******.exe 中0x00000000772CA267 (ntdll.dll) 处未处理的异常:0xC0000
- 未处理的异常与 cudaMemcpy2D
- 处理未处理的异常更改C++
- for 循环中未处理的异常
- VisualC++ 2010 有没有办法找出有关未处理异常错误的更多详细信息
- 为什么此代码导致未处理的异常失败
- 瓦尔格林德:注意到但未处理的国际奥克特尔;是否有必要处理以及如何找到?
- 在OpenCV_core310.dll中使用findContours函数时,OpenCV引发未处理的异常
- 0x0F50DF58:0xC0000005:访问冲突读取位置0x0047CA04时未处理的异常
- 使用 getline 时未处理的异常
- 错误 : 异常 : 引发未处理的异常: 读取访问冲突.0xDDDDDDDD临时温度
- 核心消息传递中未处理的异常.dll在程序关闭期间
- 在 Hello World.exe 中0x0F828F0E (ucrtbased.dll) 处未处理的异常: 0xC00
- 从向量中删除元素时未处理的异常
- QML:多个键按 /发布后未处理一些键
- C++ 程序中双链表的未处理异常