搜索了一段时间,但我不明白为什么这会引发总线错误。
如有任何帮助,我们将不胜感激。
typedef struct {
set<int> pages;
} someStruct;
...
void someFunction() {
...
someStruct *a = createSomeStruct(); // just mallocs and returns
a->pages.insert(5);
...
}
最佳答案
malloc 不会初始化它分配的内存。尝试新的。
关于c++ - "Bus error"从结构访问集合<int>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/601680/