【发布时间】:2021-07-30 09:31:38
【问题描述】:
我无法理解为什么这个简单的代码会出现分段错误。
#include <iostream>
using namespace std;
int main ()
{
vector <vector <int>> graph;
graph [0] = vector <int> ();
graph [0].push_back(0);
cout << graph[0][0];
}
【问题讨论】:
-
哪一行有问题?
-
graph[0]在你使用时包含什么? -
声明所有行报错后,如果我一一注释掉。
标签: c++ vector segmentation-fault