当前位置:网站首页>报错:runtime error: reference binding to null pointer of type ‘std::vector<int, std::allocator<int>>‘

报错:runtime error: reference binding to null pointer of type ‘std::vector<int, std::allocator<int>>‘

2022-08-10 19:06:00 Alkali!

对于vector<vector<int> >
在初始化时,必须要给它开辟相应的存储空间!

解决方案:
在初始化时,当即为之开辟所需存储空间大小:

//假设二维数组空间大小为m x n
vector<vector<int> > count(m);
for(int i=0;i<m;i++)
	count[i].resize(n);

原网站

版权声明
本文为[Alkali!]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_45798993/article/details/126266388